suneetha
suneetha

Reputation:

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

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.

Upvotes: 1

Views: 5542

Answers (2)

Chris Nash
Chris Nash

Reputation: 11

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

Upvotes: 1

Richard Berg
Richard Berg

Reputation: 20784

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

Upvotes: 2

Related Questions