title: Passthrough (impersonation) authentication with ASP.NET and TFS api
body: <p>I'm trying to enable passthrough or impersonation authentication inside an ASP.NET website that uses the TFS2010 API.</p>
  <p>I've got this working correctly with Cassini, however with IIS 7.5 (Windows 7) something is going wrong.</p>
  <p>I found <a href="https://docs.microsoft.com/en-us/archive/blogs/taylaf/using-tfs-impersonation-with-the-version-control-client-apis" rel="nofollow noreferrer">this blog post</a> on the subject, and tried the following:</p>
  <pre><code>private static void Test()
  {
      TfsTeamProjectCollection baseUserTpcConnection = 
              new TfsTeamProjectCollection(new Uri(Settings.TfsServer));
      
      // Fails as 'baseUserTpcConnection' isn't authenticated
      IIdentityManagementService ims = 
              baseUserTpcConnection.GetService&lt;IIdentityManagementService&gt;();
      
      // Read out the identity of the user we want to impersonate
      TeamFoundationIdentity identity = ims.ReadIdentity(
              IdentitySearchFactor.AccountName, 
              HttpContext.Current.User.Identity.Name,
              MembershipQuery.None, 
              ReadIdentityOptions.None);
  
      TfsTeamProjectCollection impersonatedTpcConnection = new 
              TfsTeamProjectCollection(new Uri(Settings.TfsServer), 
              identity.Descriptor);
  }
  </code></pre>
  <p>When I use Cassini nothing is needed besides</p>
  <p><code>collection = new TfsTeamProjectCollection(new Uri(server));</code></p>
  <p>I have enabled the web.config settings (and have the Windows Auth module installed):</p>
  <pre><code>&lt;authentication mode=&quot;Windows&quot;/&gt;
  &lt;identity impersonate=&quot;true&quot; /&gt;
  </code></pre>
  <p>Is there something obvious that I've missed out?</p>