9

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.

leppie
  • 115,091
  • 17
  • 196
  • 297
ekrako
  • 169
  • 1
  • 11

1 Answers1

4

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

MikeR
  • 3,045
  • 25
  • 32
  • I know this is an old post. What namespace can I find IIdentityManagementService and TeamFoundationIdentity in? Is there an SDK that I need? – Bill Greer Jan 09 '18 at 17:00
  • I couldn't the tool where I used it, probably not existing anymore. I searched the net and this should be correct: https://msdn.microsoft.com/de-de/library/microsoft.teamfoundation.server.core.teamfoundationidentity.aspx – MikeR Feb 21 '18 at 10:21