Make Changes to a TFS Work Item as a specific user

爱⌒轻易说出口 提交于 2019-12-02 02:44:56
MrHinsh - Martin Hinshelwood

You need to use the 'make requests on behalf of others' functionality. You can impersonate another user by following:

public void Impersonation(Uri serverUri,string userToImpersonate)
{
    // Read out the identity of the user we want to impersonate
    TeamFoundationIdentity identity = ims.ReadIdentity(IdentitySearchFactor.AccountName, 
        userToImpersonate,
        MembershipQuery.None, 
        ReadIdentityOptions.None);

    tfs_impersonated = new TfsTeamProjectCollection(serverUri, identity.Descriptor);

    GetAuthenticatedIdentity(tfs_impersonated);

    // Use this tfs_impersonated object to communicate to TFS as the other users.
}

And make sure your account running the website has the permission to "make requests on behalf of others":

http://www.codeproject.com/Articles/104019/TFS-API-Part-TFS-Impersonation
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!