TFS 2013 get All TFS group including Windows group

2019-03-03 16:29发布

问题:

I am working on this TFS 2013 to get the project level permission of all the TFS group. But I cannot get the windows group. I use the following code to list the groups:

var applicationGroups = identityManagementService.ListApplicationGroups(project.Uri.AbsoluteUri, ReadIdentityOptions.None);

But this code will only list those TFS groups that are under Teams ([project]\Project Team) and VSO groups ([project]\Build Administrators, [project]\Contributors, [project]\Readers, [project]\Project Administrators, [project]\Project Valid Users, [project]\TFS_Build_Administrators, [project]\TFS_Build_Readers) but not Windows groups (TFS_Builder, TFS_DEV_AM...) .

Does anyone know how I can do this or why I wasn't able to get those under Windows groups?


Hi Thank you very much for replying. But I was actually looking to query all those windows groups and from there I will try to identify who are the members of each group. Your answer is also correct but it is only applicable for an individual user and try get the memberOf inorder for us to know which windows group is the user a memberOf. I just marked it as yes coz I found a way on how I could list it through that code. But I'm not sure if I might post another question for this again. Anyway. Below is the new code that is for TFS 2013 as the IGroupSecurityService is obsolete.

var collection = new TfsTeamProjectCollection(new Uri("http://mytfs:8080/tfs/MyCollection"));
var identityService = collection.GetService<IIdentityManagementService>();
var readIdentity = identityService.ReadIdentity(IdentitySearchFactory.AccountName, @"[domailName here]\" + userName, MembershipQuery.Direct, ReadIdentityOptions.None);

回答1:

Windows groups are not stored in TFS, but in Active Directory. To query Active Directory through TFS, use:

var collection = new TfsTeamProjectCollection(new Uri("http://mytfs:8080/tfs/MyCollection"));
var gss = collection.GetService<IGroupSecurityService>();
Identity i = gss.ReadIdentity(SearchFactor.AccountName, "myalias", QueryMembership.Direct);

That's a user, you can try getting groups through it as well.



标签: tfs