title: Identity of thread in self hosted WCF service when called from Web Application
body: <p>I have a Windows Service that is self hosting a Wcf service, this Wcf service has a tcpBinding with default settings. The Windows service is running as LocalSystem.</p>
  
  <p>The Wcf Service is referenced (default settings) by a Web application that is running in IIS 7.5 integrated pipeline within it's own application pool with its own identity.</p>
  
  <p>Both are running on the same machine.</p>
  
  <p>All is working fine, except that when in the Wcf Service when I check the identity of the current thread with:</p>
  
  <p>Thread.CurrentPrincipal.Identity.Name</p>
  
  <p>It returns the user of the Application Pool of the Web Application.. this is not what I expect. It looks like some sort of impersonation is going on in the Wcf service.</p>
  
  <p>Is this standard behavior? I can't find any documentation on this.
  And does it mean that when I try to access a database in the Wcf service i'm introducing a identity hop?</p>
  
  <p><strong>Edit</strong>, the config on service side:</p>
  
  <pre><code>        Type serviceType = typeof(WcfService);
          host = new ServiceHost(serviceType);
  
          Binding tcpBinding = new NetTcpBinding( );
  
          Uri tcpBaseAddress = new Uri("net.tcp://localhost:8001/Test");
          host.AddServiceEndpoint(typeof (WcfService), tcpBinding, tcpBaseAddress);
  
          host.Open();
  </code></pre>
  
  <p>On the client side:</p>
  
  <pre><code>            NetTcpBinding tcpBinding = new NetTcpBinding(SecurityMode.Transport);
          windowsService = new WindowsService.WcfServiceClient(tcpBinding, new EndpointAddress("net.tcp://localhost:8001/Test"));
  </code></pre>