【发布时间】:2020-03-16 23:34:06
【问题描述】:
我正在尝试使用 C# 编程从 TFS 下载我的代码文件。为了实现这一点,需要遵循两个步骤,
- 通过 C# 连接到 TFS
- 路由到文件夹以下载所需文件。
我目前正在执行第 1 步,为了实现这一目标,我做了一些研究并使用了 TFS API 并使用了以下代码,
public static bool AlwaysGoodCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors policyErrors)
{
return true;
}
static void Main(string[] args)
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(AlwaysGoodCertificate);
// Translate username and password to TFS Credentials
ICredentials networkCredential = new NetworkCredential(@"username", @"password", @"domain");
WindowsCredential windowsCredential = new WindowsCredential(networkCredential);
TfsClientCredentials tfsCredential = new TfsClientCredentials(windowsCredential, false);
// Connect to TFS Work Item Store
Uri tfsUri = new Uri(@"https://url");
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(tfsUri, tfsCredential);
WorkItemStore witStore = new WorkItemStore(tfs);
}
现在,我无法通过此代码连接到 TFS,每当我尝试使用浏览器通过输入相同的 url、密码、域和用户名进行连接时,我都会成功登录,但由于某些奇怪的原因,我无法登录使用我的代码。当我尝试通过代码登录时收到以下错误,
【问题讨论】:
-
我不确定,我该如何检查。但我认为它是在prem
-
是的,我们有一个专用服务器。所以我想它是在prem然后
-
如何查看端口和 CollectionName?
-
这是什么?我可以打开这个链接
-
我的该怎么办?我怎样才能让它发挥作用?
标签: c# authentication tfs connection tfsbuild