尝试连接到Team Foundation Server时出错

时间:2014-08-04 18:22:47

标签: c# tfs azure-devops networkcredentials

我正在尝试连接到我们的在线TFS。这就是我目前所拥有的:

NetworkCredential cred = new NetworkCredential(textBox_Username.Text, 
    textBox_password.Password);
Uri TFSurl = new Uri("https://myCompany.visualstudio.com/DefaultCollection");
TfsConfigurationServer tfs = new TfsConfigurationServer(TFSurl, cred);
tfs.EnsureAuthenticated();

这引起了我的注意:

  

TF30063:您无权访问https://actacom.visualstudio.com/DefaultCollection

输入的凭据是正确的。

2 个答案:

答案 0 :(得分:1)

选中此blog post,它有一个示例代码,说明如何操作。我已经用我的VSO帐户尝试了它,它工作得很好。

答案 1 :(得分:0)

博客帮助了我。 对于其他人,这是工作代码。

 NetworkCredential netCred = new NetworkCredential(
                textBox_Username.Text,
                textBox_password.Password);
                BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
                TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
                tfsCred.AllowInteractive = false;

                TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(
                    new Uri("https://fabrikam.visualstudio.com/DefaultCollection"),
                    tfsCred);

                tpc.Authenticate();
相关问题