Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS get user by name

Tags:

c#

.net

tfs

I'm trying to add a test run by the TFS API from excel.
In one of the field in the excel I got the user who executed the tests.
I want to update it in the server in order to update it I need to get the user as TeamFoundationIdentity

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

Please help me to fix it.

like image 512
ekrako Avatar asked Jan 24 '13 13:01

ekrako


1 Answers

Which version of Visual Studio and TFS are you using? I'm using 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 the initialistation of IIdentityManagementService, you could give it a try. I suspect that _tfs is a valid representation of a TfsTeamProjectCollection

like image 186
MikeR Avatar answered Sep 21 '22 13:09

MikeR