TFS WorkItem permission with assignment and creation to email address

I work with some custom reports in TFS. I have a set of instances WorkItemthat I want to receive from the Creator and the Assigned-From.

WorkItem wi = GetWorkItem( ... );
String assignedTo = (String)wi.Fields[CoreField.AssignedTo].Value;
String createdBy  = (String)wi.Fields[CoreField.CreatedBy].Value;

The problem is that the fields are raw string values ​​containing the display name of the user. I have to keep my own database that maps these display names to their Active Directory identifiers (by their username or email address).

Obviously, maintaining your own parallel user database is not the case - is there any other way to get the wi.Fields[CoreField.AssignedTo].Valuesecurity authentication object from the object, or at least the user's username or email address?

+3
source share
1 answer

You can use IIdentityManagementService2( http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.framework.client.iidentitymanagementservice2.aspx ) to get detailed identifier information using the display name. You can get the service in the same way as you get WorkItemStorefrom the project collection object using TfsTeamProjectCollection.GetService<IIdentityManagementService2>(). If you enter a value AssignedToin a string, you can use the following code to get an identity:

var identity = identityService.ReadIdentity(
            IdentitySearchFactor.DisplayName, 
            assignedTo, 
            MembershipQuery.Direct,
            ReadIdentityOptions.ExtendedProperties);

Where AssignedTois the display name value that you retrieve from the field in the work item.

+3
source

All Articles