我正在尝试访问https://visualstudio.com(原名https://tfs.visualstudio.com, http://www.tfspreview.com)来自我在 .NET 上编写的 Windows 服务。
我想使用新的基本身份验证,但找不到方法。
我发现了很多博客文章的链接Team Foundation 服务更新 - 8 月 27 日但它使用 Team Explorer Everywhere Java 客户端进行 TFS。
是否有新版本的 TFS .NET 对象模型支持基本身份验证?
顺便说一句,我已经成功使用服务帐户登录了。这个答案非常有用。
首先,你至少需要有Visual Studio 2012 更新 1安装在您的机器上。它包括一个更新的Microsoft.TeamFoundation.Client.dll
装配与BasicAuthCredential
class.
这是执行此操作的代码,来自Buck 的博客文章如何连接到 Team Foundation Service.
using System;
using System.Net;
using Microsoft.TeamFoundation.Client;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
NetworkCredential netCred = new NetworkCredential(
"[email protected]",
"yourbasicauthpassword");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(
new Uri("https://YourAccountName.visualstudio.com/DefaultCollection"),
tfsCred);
tpc.Authenticate();
Console.WriteLine(tpc.InstanceId);
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)