我们可以模拟 Windows 用户访问 TFS 或 TFS Web 吗? [英] Can we impersonate Windows user to TFS or TFS web access?

查看:30
本文介绍了我们可以模拟 Windows 用户访问 TFS 或 TFS Web 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以模拟 Windows 用户访问 TFS 或 TFS 网络?

Is it possible to impersonate Windows user to TFS or TFS web access?

推荐答案

是的,这是可能的.你会想要做这样的事情:

Yes, it is possible. You will want to do something like this:

NetworkCredential serviceUser = new NetworkCredential(username, password, domain);
ICredentialsProvider TfsProxyCredentials = new NetworkCredentialsProvider(serviceUser);
Uri tpcUri = new Uri("http://yourserver:8080/tfs/yourCollectionName");
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(tpcUri, serviceUser);

// Get the TFS identity management service
IIdentityManagementService ims = tpc.GetService<IIdentityManagementService>();

// Look up the user that we want to impersonate
TeamFoundationIdentity identity = ims.ReadIdentity(IdentitySearchFactor.AccountService, userToImpersonate, MembershipQuery.None, ReadIdentityOptions.None);

TfsTeamProjectCollection impersonatedCollection = new TfsTeamProjectCollection(tpcUri, serviceUser, TfsProxyCredentials, identity.Descriptor);

return impersonatedCollection;

请注意,服务用户必须具有代表其他用户操作的权限.您的 TFSService 通常具有该权限.

Note that the service user must have the permissions to act on behalf of other users. Your TFSService typically has that privilege.

这篇关于我们可以模拟 Windows 用户访问 TFS 或 TFS Web 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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