TFS通过名称获取用户 [英] TFS get user by name

查看:47
本文介绍了TFS通过名称获取用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试添加来自excel的TFS API运行的测试.
在excel的其中一个字段中,我找到了执行测试的用户.
我想在服务器中更新它以便更新它,我需要将用户作为 TeamFoundationIdentity

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);

请帮助我修复它.

推荐答案

您正在使用哪个版本的Visual Studio和TFS?我正在使用TFS2010和VS2010,以下代码对我来说效果很好:

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);

不确定问题是否仅是 IIdentityManagementService 的初始化,您可以尝试一下.我怀疑 _tfs TfsTeamProjectCollection

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

这篇关于TFS通过名称获取用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆