gpt4 book ai didi

c# - 从 WebService 连接到 Visual Studio Team Services

转载 作者:行者123 更新时间:2023-11-30 17:55:08 25 4
gpt4 key购买 nike

我如何向 TfsTeamProjectCollectionFactory.GetTeamProjectCollection 提供凭据?
我正在尝试从女巫开发我自己的 WCF 服务,我将向 TFS 提出请求
我需要此 WCF 服务,因为我想在无法使用 Microsoft.TeamFoundation.* dll 的情况下通过移动设备管理我的 TFS 文件

我一直在尝试这种方式

Uri tpcAddress= new Uri("https://myserver.visualstudio.com/DefaultCollection");
TfsConnection tfsc = new TfsConfigurationServer(tpcAddress,
new NetworkCredential("mail@example.com", "password"));
TfsWebClient wc = new TfsWebClient(tfsc);
tfsc.Connect(ConnectOptions.IncludeServices);

第二次尝试使用派生自 ICredentialsProvider 的自定义类

ICredentialsProvider prov = new myCredentials();
var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpcAddress, prov);
tpc.EnsureAuthenticated();
tpc.Authenticate();

public class myCredentials : ICredentialsProvider
{
public ICredentials GetCredentials(Uri uri, ICredentials failedCredentials)
{
return new NetworkCredential("mail@example.com", "password");
}
public void NotifyCredentialsAuthenticated(Uri uri)
{
}
}

但它只在我的机器上工作,因为我登录到 tfs。

最佳答案

为避免提示使用您的 Live ID 登录或必须已经登录,您需要启用备用登录凭据并将其用于您的服务。

这篇博文告诉您如何:

http://blogs.msdn.com/b/buckh/archive/2013/01/07/how-to-connect-to-tf-service-without-a-prompt-for-liveid-credentials.aspx

请注意,您需要安装 VS 2012 Update 1 才能使用此功能。

希望这对您有所帮助。

关于c# - 从 WebService 连接到 Visual Studio Team Services,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15317191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com