我正在尝试访问 https://visualstudio.com (以前称为 https://tfs.visualstudio.com 、 http://www.tfspreview.com )来 self 在 .NET 上编写的 Windows 服务。
我想使用新的基本身份验证,但找不到实现它的方法。
我找到了很多博客文章的链接 Team Foundation Service updates - Aug 27但它正在为 TFS 使用 Team Explorer Everywhere Java 客户端。
是否有新版本的 TFS .NET 对象模型支持基本身份验证?
顺便说一句,我已经使用服务帐户成功登录了。 This answer非常有用。
最佳答案
首先,你至少需要有Visual Studio 2012 Update 1安装在你的机器上。它包含更新的 Microsoft.TeamFoundation.Client.dll
程序集和 BasicAuthCredential
类。
这是执行此操作的代码,来自 Buck's blog post How to connect to 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(
"yourbasicauthusername@live.com",
"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);
}
}
}
关于c# - 如何使用 .Net Windows 服务的新基本身份验证对 Visual Studio Team Services 进行身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13245776/