TFS api 未验证凭据 [英] TFS api not validating the credentials
本文介绍了TFS api 未验证凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的 windows 窗体应用程序中有以下代码:
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);
};
这是有效的.问题是 TeamFoundationServer
是一个过时的类.
This is working. The problem is TeamFoundationServer
is an obsolete class.
TeamFoundationServer 类已过时.使用 TfsTeamProjectCollection 或 TfsConfigurationServer 类与 2010 Team Foundation Server 对话.为了与 2005 或 2008 Team Foundation Server 通信,请使用 TfsTeamProjectCollection 类.
我现在正在使用以下代码,但它不会验证我的凭据.我在这里做错了什么?
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);
}
这是 MyCrendentials 类:
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
}
提前致谢!
推荐答案
我知道这是一个老问题,但我曾经问过同样的问题.
I know it's an old question, but I was asking the same question at one point.
NetworkCredential credentials = NetworkCredential("User", "Password", "Domain");
TfsConfigurationServer tfs = new TfsConfigurationServer(new Uri("Address"), credentials);
tfs.Authenticate();
这篇关于TFS api 未验证凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文