如何使用特定凭据连接到 C# 中的 TFS 服务器? [英] How do you connect to a TFS server in C# using specific credentials?

查看:11
本文介绍了如何使用特定凭据连接到 C# 中的 TFS 服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个连接到 TFS 并检索工作项信息的 c# 应用程序.不幸的是,似乎所有使用 TFS SDK 的示例都使用当前用户的默认凭据(即我的域登录信息).我找到的最接近的信息是使用 TeamFoundationServer (String, ICredentials) 构造函数,但是我找不到与 ICredentials 接口接口的合适类的任何信息(特别是因为它似乎没有使用 System.Net ICredentials,而是使用 TeamFoundationServer 特定的 ICredentials).

I am attempting to write a c# application that connects to TFS and retrieves work item information. Unfortunately, it seems like all examples of using the TFS SDK are using the default credentials for the current user (i.e. my domain login information). The closest piece of information I found is to use the TeamFoundationServer (String, ICredentials) constructor, however I cannot find any information for a suitable class that interfaces with the ICredentials interface (especially since it seems to not be using the System.Net ICredentials but a TeamFoundationServer specific ICredentials).

有人知道使用特定的用户名/密码/域组合登录 TFS 吗?

Does anyone have any insight for logging into TFS with a specific username/password/domain combination?

推荐答案

以下代码应该对您有所帮助:

The following code should help you:

NetworkCredential cred = new NetworkCredential("Username", "Password", "Domain");
tfs = new TeamFoundationServer("http://tfs:8080/tfs", cred);
tfs.EnsureAuthenticated();

域是实际域,或者在工作组情况下,它是托管 TFS 应用程序层的服务器的名称.

Domain is either the actual domain, or in a Workgroup situation, it would be the name of the server that hosts the TFS Application Tier.

这篇关于如何使用特定凭据连接到 C# 中的 TFS 服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆