Suneetha
Suneetha

Reputation:

Unable to send TFS credentials

I am trying to send TFS credentials to the server for connecting TFS server using below code

TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer().

This method is expecting two input parameters.one is of type string(tfs url as string) and another one is of type ICredentialsProvider.I am unable to create instance of this class and unable to send TFS credentials to Getserver method.Please help me if any body has idea about it.

Thanks Suneetha.

Upvotes: 1

Views: 3402

Answers (2)

Alex
Alex

Reputation: 13249

NetworkCredential networkCredential;

        if (Username != null && Password != null)
        {
             if (Domain != null)
                  networkCredential = new NetworkCredential(Username, Password, Domain);
             else
                  networkCredential = new NetworkCredential(Username, Password);
         }
         else
         {
              networkCredential = CredentialCache.DefaultNetworkCredentials;
         }


        TeamFoundationServer TFS = new TeamFoundationServer( stringTFSURL, networkCredentials);

Upvotes: 0

dariom
dariom

Reputation: 4578

What sort of errors are you getting when you create an ICredentialsProvider?

You should be able to instantiate a UICredentialsProvider object that implements ICredentialsProvider.

Alternatively you can construct a TeamFoundationServer instance and pass credentials through the constructor.

These links might help:

Upvotes: 5

Related Questions