Search code examples
tfstfs-sdk

How does the EnsureAuthenticated in the TFS API Work?


I'm working on a web application that works with the TFS API and I would like to make sure that any users that use it have the proper authentication to use TFS.

To do so I use the following code:

TfsTeamProjectCollection teamProjectCollection = configServer.GetTeamProjectCollection(collectionId);
teamProjectCollection.EnsureAuthenticated;

I'm going to host the website on IIS.

When a user uses the web app, will EnsureAuthenticated use their credentials, or will it use the credentials of the remote desktop I'm hosting the application on?


Solution

  • It depends.

    If you have configured ASP.NEt to use impersonation, it will use the account of the logged user.

    If ASP.NET is configured with default settings there are a number of things that can happen

    • If there is a credential stored in the Credentials Manager it will use that
    • If the application pool is running under a real account it will try to do that
    • If the application pool is running an application pool account, it will probably try to authenticate with the System's account (COMPUTER$)

    I'd say, try it and look at the IIS logs of your TFS server or use something like fiddler to capture the traffic.