TFS gets user by name

I am trying to add a test run of the TFS API from excel.
In one of the fields in excel, I got the user who ran the tests.
I want to update it on the server in order to update it. I need the user to become TeamFoundationIdentity

 ims = _tfs.GetService<IIdentityManagementService>(); TeamFoundationIdentity UserID = ims.ReadIdentity(IdentitySearchFactor.DisplayName, userName, ReadIdentityOptions.None); 

Please help me fix this.

+8
c # tfs
source share
1 answer

What version of Visual Studio and TFS are you using? I use TFS2010 and VS2010, and the following code worked fine for me:

 IIdentityManagementService ims = (IIdentityManagementService)_tfs.GetService(typeof(IIdentityManagementService)); TeamFoundationIdentity UserID = ims.ReadIdentity(IdentitySearchFactor.DisplayName,"Mike" , MembershipQuery.Direct, ReadIdentityOptions.None); 

Not sure if the problem is just initializing IIdentityManagementService , you can try. I suspect _tfs is a valid representation of a TfsTeamProjectCollection

+4
source share

All Articles