How to get TFS user groups and users in particular group using TFS API?

£可爱£侵袭症+ 提交于 2020-01-11 12:20:52

问题


I want to list TFS user groups in a DropDown and based on selection of user group I need to populate users in that particular group using TFS API.


回答1:


This page has several examples: http://blogs.microsoft.co.il/blogs/shair/archive/2009/01/14/tfs-api-part-4-get-tfs-user-list-mail-sid-account-domain.aspx

The last example is probably the most relevant.

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



回答2:


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


来源:https://stackoverflow.com/questions/1097713/how-to-get-tfs-user-groups-and-users-in-particular-group-using-tfs-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!