Make Changes to a TFS Work Item as a specific user

谁都会走 提交于 2019-12-02 06:25:01

问题


I am working on creating a Web application, which the users in my team will use to make changes to TFS Work Items. I am using TFS API for this..

In order to access the TFS Server , I used my credentials within the Web Application.

Now each time someone uses the application and makes changes to TFS work items, it shows as if I have made changes to these items since my credentials are being used in the application.

Is there a way I can use the credentials of the person logging into my application to show up on TFS as the person making the changes ?


回答1:


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

来源:https://stackoverflow.com/questions/26965197/make-changes-to-a-tfs-work-item-as-a-specific-user

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