I have the following code on my windows form application:
// Connect to server
var tfs = new TeamFoundationServer(tfsServer, credentials);
try
{
tfs.EnsureAuthenticated();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
};
This is working. The problem is TeamFoundationServer
is an obsolete class.
The TeamFoundationServer class is obsolete. Use the TfsTeamProjectCollection or TfsConfigurationServer classes to talk to a 2010 Team Foundation Server.
In order to talk to a 2005 or 2008 Team Foundation Server use the TfsTeamProjectCollection class.
I am using the below code now but it doesn't validate my credentials. What did I do wrong here?
NetworkCredential credentials = new NetworkCredential(username, password, domain);
MyCredentials credentials = new MyCredentials(username, password, domain);
TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsServer), credentials);
try
{
tfs.EnsureAuthenticated();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
This is the MyCrendentials class:
private class MyCredentials : ICredentialsProvider
{
private NetworkCredential credentials;
#region ICredentialsProvider Members
public MyCredentials(string user, string domain, string password)
{
credentials = new NetworkCredential(user, password, domain);
}
public ICredentials GetCredentials(Uri uri, ICredentials failedCredentials)
{
return credentials;
}
public void NotifyCredentialsAuthenticated(Uri uri)
{
throw new NotImplementedException();
}
#endregion
}
Thanks in advance!