我擁有本地tfs 2012.在Visual Studio 2012上,使用c#,我編寫了通過編程連接到tfs服務器的程序。但我有錯誤:以編程方式授權給tfs的錯誤
{"TF30063: You are not authorized to access 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
你能幫我解決這個錯誤?
P.S.我嘗試做連接這種方式,但我有同樣的錯誤:
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(「http:// server:8080/tfs/」); –
此外,如果你在一個域中,你應該使用域名的憑據.... NetworkCredential netCred = new NetworkCredential(「login」,「password」,「DomainName」); –