0
votes

I am fetching the workitems in TFS using following approach.

WorkItem workItem = workItemClient.getWorkItemByID(workItemId);

Now to get 'Created By' && 'Assigned To' , I am using fieldCollection

FieldCollection fieldCollection = workItem.getFields();
Field createdBy = fieldCollection.getField("Created By");
Field assignedTo = fieldCollection.getField("Assigned To");

the above approach always gives me the display name of user instead of unique user name (Account name).

To resolve the display name with username(account name), I am making a query to TFS server

tfsUser = identityManagementService.readIdentity(IdentitySearchFactor.DISPLAY_NAME, displayName, MembershipQuery.DIRECT,ReadIdentityOptions.NONE);

But this query return an error "

Multiple identities were found that matched the factor value 'display name'

Any Idea on how can we get the Account name of user instead of display name for work items in TFS

1

1 Answers

0
votes

You need to use the ReadIdentities() method to list the display name in an array to return Identity for each user use ReadIdentities by Sid.

Identity[] UserId = IIdentityManagementService.ReadIdentities(SearchFactor.Sid, SIDS.Members, QueryMembership.None);

Check this blog and demo for more details. This blog is still using IGroupSecurityService interface, but IGroupSecurityService is obsolete. You need to use the IIdentityManagementService or ISecurityService instead.