【发布时间】: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");