[英]Can we impersonate Windows user to TFS or TFS web access?
是否可以模擬Windows用戶使用TFS或TFS Web訪問?
對的,這是可能的。 您將需要執行以下操作:
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通常具有該特權。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.