Force Synchronizing TFS 2013 Users with Windows Accounts

Sometimes we need to add users to our AD or Windows so we can add them to the TFS and we need them to appear immediately without needing to wait for the synchronization to happen automatically.

There are many ways that we can do that….I will explain how to do that with different methods.

TFS Job Agent is responsible for running this sync and other jobs, by default this run once an hour, we can run this job using the Web Service “JobWebService” or by using TFS Client Object Model “Microsoft.TeamFoundation.Client“.

We can use the Client Object Model with C# Console Application for example or using it with PowerShell script.

Use the JobWebService directly.

We need to call QueueJobs web service but unfortunately we can’t call that from the browser, remember that we need also the GUID of the job

Navigate to the TFS admin Web Services.Open Webservice

Open the JobService Web Services and click on QueueJobs Web Service.QueueJobs WebService

We can’t call it from the browser and we need the GUID of the Job.Call QueueJobs

Use the WebServiceStudio.

We can use a very smart tool WebServiceStudio that existing on CodePlex, this tool enables us to call the Web Service with GUI and without writing code for the Web Service.QueueJobs using WebServiceStudio

Use a PowerShell Script.

We also can use TFS Client Object Model “Microsoft.TeamFoundation.Client” with PowerShell script.PowerShell
Download the script

I made the demo on Brain Keller VM, here are the steps you need to follow:

Add your user to your AD or Local accounts for work group.Add Users to Windows

Remember that We adding the Windows Group to the TFS Collection, in our case the Administrators group.Administrators added to the project collection

We will run the job using any method and then the users will start to appear immediately.The user will appear in TFS

To view what is the status of the job, queue time, start time or end time, run the following SQL script on DT (Data Tire) don’t confuse with the time because it’s UTC

[code language=”sql”]
USe tfs_Configuration
SELECT TOP 100 *
FROM [Tfs_Configuration].[dbo].[tbl_JobHistory]
WHERE JobId=’544DD581-F72A-45A9-8DE0-8CD3A5F29DFE’
[/code]

tbl_JobHistory
To make sure about job name and other info, run the following script:

[code language=”sql”]
use tfs_Configuration
SELECT TOP 100 *
FROM [Tfs_Configuration].[dbo].[tbl_JobDefinition]
WHERE JobId=’544DD581-F72A-45A9-8DE0-8CD3A5F29DFE’
[/code]

tbl_JobDefinition


Share This: