【问题标题】:Error authorized to tfs programmatically以编程方式授权给 tfs 的错误
【发布时间】:2014-03-25 08:29:12
【问题描述】:

我有本地 tfs 2012。在 Visual Studio 2012 上,使用 c#,我编写以编程方式连接到 tfs 服务器的程序。但我有错误:

{“TF30063:您无权访问http://server:8080/tfs。”} System.Exception {Microsoft.TeamFoundation.TeamFoundationServerUnauthorizedException}

我的代码:

Uri collectionUri = new Uri("http://server:8080/tfs");
NetworkCredential netCred = new NetworkCredential("login","password");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;
TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(collectionUri, netCred);
teamProjectCollection.EnsureAuthenticated();//throw error here

你能帮我解决这个错误吗?

附:我尝试以这种方式连接,但我有同样的错误:

var projectCollection = new TfsTeamProjectCollection(
new Uri("http://myserver:8080/tfs/DefaultCollection"), 
new NetworkCredential("youruser", "yourpassword"));

projectCollection.Connect(ConnectOptions.IncludeServices);

这样:

Uri collectionUri = new Uri("http://server:8080/tfs/DefaultCollection");
NetworkCredential netCred = new NetworkCredential("login","password","Server.local");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;
TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(collectionUri, netCred);
teamProjectCollection.EnsureAuthenticated();

【问题讨论】:

  • 你试过在uri中使用集合名吗... Uri collectionUri = new Uri("server:8080/tfs/<CollectionName>");
  • 此外,如果您在域中,则应使用域名作为凭据.... NetworkCredential netCred = new NetworkCredential("login","password","DomainName");

标签: c# tfs


【解决方案1】:

希望对你有帮助。

var tfsCon = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://server:8080/tfs"));
tfsCon.Authenticate();
var workItems = new WorkItemStore(tfsCon);
var projectsList = (from Project p in workItems.Projects select p.Name).ToList();

Uri TfsURL = new Uri(""http://server:8080/tfs"");
NetworkCredential credential = new NetworkCredential(Username, Password, Domain);
TfsTeamProjectCollection collection = new TfsTeamProjectCollection(TfsURL, credential);
collection.EnsureAuthenticated();

如果此处失败,则需要在 App.config 中进行配置以设置默认代理:

<?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <system.net>
      <defaultProxy enabled="true" useDefaultCredentials="true"></defaultProxy>
   </system.net>
</configuration>

【讨论】:

  • 您能与我们分享解决您的问题的哪些选项吗?尝试使用与您的原始帖子几乎完全相同的代码连接到我们的本地 TFS 服务器时,我也遇到了 TF30063 错误。
猜你喜欢
  • 2015-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-16
  • 2019-04-14
  • 2018-01-18
  • 2021-02-14
相关资源
最近更新 更多