Thursday, March 20, 2014

TFS - Multiple identities found matching "xx, xx"

I received an email today from a TFS user trying to import using Team Explorer Everywhere through Eclipse and encountering an identity collision error:

"Multiple identities found matching "LastName, FirstName". Use the unique name to specify one of the following identities:

LastName, FirstName(unique name DOMAIN\USER1)
LastName, FirstName(unique name DOMAIN\USER2)


Based on the error message, it appears as if there were two users in the [tbl_Identity] TFS DB with the same Display Name.  Running a quick SQL query confirmed my suspicion:

 SELECT     
     [ProviderDisplayName]  
    ,[DisplayName]  
    ,[HasDisplayName]  
    ,[Domain]  
    ,[AccountName]  
    ,[UniqueUserId]  
    ,[LastSync]  
  FROM [Tfs_Configuration].[dbo].[tbl_Identity] where displayname like '%name_of_user%'  

This query returns a list of users matching the account name of the user in question.  Sure enough, there were two users with the same display name, but different account name's.  Looking in active directory, I could see same thing.  However, the name field on the two accounts was different, but NOT the display name.  So, the trick is to change the display name on the user and not simply the name.  Once you have changed the display name in AD, you can either wait for TFS to run the AD sync job or force the sync using the PS script below:

 [Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")  
 # connect to the server  
 $credProvider = new-object Microsoft.TeamFoundation.Client.UICredentialsProvider  
 $tfsConnection = new-object Microsoft.TeamFoundation.Client.TfsConfigurationServer "http://localhost:8080/tfs", $credProvider  
 $tfsConnection.EnsureAuthenticated()  

 # force a full sync on the next sync execution.  
 $tfRegistry = $tfsConnection.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationRegistry])  
 $tfRegistry.SetValue('/Service/Integration/Settings/IdentitySyncFull', $true)  
 
# Kick the IMS periodic job so that it syncs.  
 $jobIds = [Guid[]] @('544DD581-F72A-45A9-8DE0-8CD3A5F29DFE')  
 $jobSvc = $tfsConnection.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationJobService])  
 $jobSvc.QueueJobsNow($jobIds, $true)  

 # Optional: Run this repeatedly till you see a recent job result.  
 # See if the job succeeded.  
 $jobSvc.QueryJobHistory($jobIds) | select -last 1  

Once you run the script above, give it a few minutes, then recheck the [tbl_Identity] TFS DB.  You should shortly see the display name of the user in question change to that of the new display name from AD.  Retry your import using Team Explorer Everywhere.  Also, I think this issue may have been fixed in the most recent version released several days ago.

No comments:

Post a Comment