How to get a list of valid users
-
Tuesday, March 27, 2012 2:27 PM
I was trying to get a list of valid users from team server and I had no success. I found a example in C# and I tryied to convert o java, I didn't find some corresponding classes like GroupSecurityService and TeamFoundationServer. How I can do this?
this is what a want to do in java:
private TeamFoundationServer tfs; public void ShowValidUsers(WorkItem wi) { WorkItem workItem = wi; // show basic information Console.WriteLine("Select Work Item {0} ({1})", workItem.Id.ToString(), workItem.Title); // get the Group Security Service IGroupSecurityService gsService = (IGroupSecurityService)tfs.GetService(typeof(IGroupSecurityService)); // retrieve all application groups (by default: Contributors, Project Administrators, Build Services and Readers) // for the project this Work Item belongs to. Application groups do not contain member information. Identity[] applicationGroups = gsService.ListApplicationGroups(workItem.Project.Uri.AbsoluteUri); // for each application group foreach (Identity applicationGroup in applicationGroups) { // unless this is the Readers group (By default Readers do not have permissions to add/edit Work Items) if (applicationGroup.DisplayName != "Readers") { // retrieve the application group again (this time with members information) Identity[] groupContainer = gsService.ReadIdentities(SearchFactor.Sid, new string[] { applicationGroup.Sid }, QueryMembership.Expanded); // for each group (container contains only one group) foreach (Identity group in groupContainer) { // if this group has any members if (group.Members != null) { // for each member in this group foreach (string projectMemberSid in group.Members) { // get member(valid user) details Identity validUser = gsService.ReadIdentity(SearchFactor.Sid, projectMemberSid, QueryMembership.None); Console.WriteLine("valid user: {0}", validUser.DisplayName); } } } } } }
All Replies
-
Tuesday, March 27, 2012 3:36 PM
Hi,
you can retrieve the valid TFS users through querying the work item meta data for each team project.
Please let me know if you need a code sample on how to do that.
Thanks
Mireille
- Proposed As Answer by Mireille HannaMicrosoft Employee Tuesday, March 27, 2012 3:36 PM
-
Wednesday, March 28, 2012 3:14 PM
Thank you Mireille.
I would appreciate an example. I tried to make a query here but i didn't work. It brings just the user which the work item is assigned to. I don't know how to get the total list of users.
WorkItemCollection workItemCollection = workItemClient.query( " SELECT [System.Id], [System.WorkItemType]," + " [System.State], [System.AssignedTo], [System.Title] " + " FROM WorkItems " + " WHERE [System.TeamProject] = '" + "e-FORMS " + "'AND [System.State] = 'ACTIVE" + "' ORDER BY [System.WorkItemType], [System.Id]"); WorkItem workItemClient = workItemCollection.getWorkItem(0);
-
Wednesday, March 28, 2012 5:34 PM
Thank you very much Mireille!
After querying I can get list of users:
workItem.getFields().getField("Assigned To").getFieldDefinition().getAllowedValues();
- Marked As Answer by Martin WoodwardMicrosoft Employee, Owner Friday, March 30, 2012 3:32 AM

