我正在尝试在VisualStudio 2010中创建一个独立的WinForm,它访问Team Services代码库并将最新文件返回到我的本地Windows文件夹。但是,我不断收到以下错误:
TF30063: You are not authorized to access the server.
TF30064: You are not authorized to access the server.
唯一有效的访问方式是使用我不想要的默认凭据,因为它们只能在打开visual studio时使用,并且tfs已登录 - 无法将其作为独立的winform使用
这是我的代码:
string teamProjectCollectionUrl = "https://xxxx.visualstudio.com/DefaultCollection";
NetworkCredential iCred = new NetworkCredential(emailUsername, password);
TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(new Uri(teamProjectCollectionUrl), iCred);
VersionControlServer versionControlServer = teamProjectCollection.GetService<VersionControlServer>();
Workspace workspace = versionControlServer.GetWorkspace(sourcePath);
//For Initial Setup
WorkingFolder workfolder = new WorkingFolder(@"$\project\subproject", sourcePath);
workspace.CreateMapping(workfolder);
workspace.Get();
答案 0 :(得分:1)
我最终使用Visual Studio 2013中的备用凭据执行此操作:
NetworkCredential netCred = new NetworkCredential("altUserName", "altPassword");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;
TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(new Uri(teamProjectCollectionUrl), tfsCred);
teamProjectCollection.Authenticate();
teamProjectCollection.EnsureAuthenticated();
VersionControlServer versionControlServer = teamProjectCollection.GetService<VersionControlServer>();
Workspace workspace = versionControlServer.GetWorkspace(localPath);
// WorkingFolder workfolder = new WorkingFolder(serverPath, localPath);
// workspace.CreateMapping(workfolder);
GetStatus getStatus = workspace.Get();
请参阅以下超级有用的链接:
答案 1 :(得分:0)
首先,在代码中删除此行NetworkCredential iCred = new NetworkCredential(emailUsername, password);
。
然后您可能需要删除Windows凭据中的帐户和密码(控制面板 - &gt;管理Windows凭据)。现在您可以输入用户名和密码。