Cannot get list of valid users in TFS for AssignedTo field when creating new Workitems via API

Hey. I am trying to create new work items through the TFS API, and this is the method I used below to get a list of valid users to which work items can be assigned. Somehow, this gives me an exception with a null reference in the validUserSids line. Does anyone know what's wrong here?

private string[] TFSUsers(string server) { // Get a Reference to Team Foundation Server. TeamFoundationServer tfs = tfsdata.GetTFS(server); // Get a reference to Group Security Service. IGroupSecurityService gss = (IGroupSecurityService)tfs.GetService(typeof(IGroupSecurityService)); // Resolve to SIDs Identity validUserSids = gss.ReadIdentity(SearchFactor.AccountName, "TFS Valid Users", QueryMembership.Expanded); // Resolve to actual users Identity[] validUsers = gss.ReadIdentities(SearchFactor.Sid, validUserSids.Members, QueryMembership.None); List<string> Users = new List<string>(); foreach (Identity user in validUsers) { Users.Add(user.DisplayName); } return Users.ToArray(); } 
+4
source share
1 answer

Here's how you get the list of users in TFS:

 var tfs = TeamFoundationServerFactory.GetServer("http://vstspioneer:8080/tfs/VSTSDF"); var workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore)); var allowedValues = workItemStore.FieldDefinitions[CoreField.AssignedTo].AllowedValues; foreach (String value in allowedValues) { Console.WriteLine(value); } 
+6
source

All Articles