简体   繁体   中英

Make Changes to a TFS Work Item as a specific user

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM