如何使用TFS API获取特定组中的TFS用户组和用户?

时间:2009-07-08 12:17:06

标签: tfs

我想在DropDown中列出TFS用户组,并根据用户组的选择,我需要使用TFS API填充该特定组中的用户。

2 个答案:

答案 0 :(得分:2)

此页面有几个示例:http://blogs.microsoft.co.il/blogs/shair/archive/2009/01/14/tfs-api-part-4-get-tfs-user-list-mail-sid-account-domain.aspx

最后一个例子可能是最相关的。

IGroupSecurityService gss = (IGroupSecurityService)server.GetService(typeof(IGroupSecurityService));
Identity[] UserId = gss.ReadIdentities(SearchFactor.Sid, SIDS.Members, QueryMembership.None);

答案 1 :(得分:1)

// Connect to the team project collection.
TfsConfigurationServer tfsServer = m_tfsServer;
Guid collectionGuid = m_collectionGuid;
TfsTeamProjectCollection tpc = tfsServer.GetTeamProjectCollection(collectionGuid);

// Get the group security service.
var gss = tpc.GetService<IGroupSecurityService2>();

// Retrieve each user's SID.
Identity sids = gss.ReadIdentity(SearchFactor.AccountName, "[My Team Project]\\Contributors", QueryMembership.Expanded);

// Resolve to named identities.
Identity[] users = gss.ReadIdentities(SearchFactor.Sid, sids.Members, QueryMembership.None);