title: How to impersonate a user to a WCF service?
body: <p>I am authenticating a user on to a WCF service via IIS7 using Windows Authentication and ASP.NET Impersonation.</p>
  
  <p>When debugging locally I am able to see the System.Security.Principal.WindowsIdentity.GetCurrent().Name as equal to my Windows credentials. When I deploy this service to a server, the WCF fails to run unless Anonymous Authentication is enabled.</p>
  
  <p>So, <strong>how do we get this WCF service to run on a server with Anonymous Authentication <em>disabled</em></strong>?</p>
  
  <p><strong>UPDATE 1</strong>: Error message after trying both suggestions:</p>
  
  <blockquote>
    <p>The authentication schemes configured on the host
    ('IntegratedWindowsAuthentication') do not allow those configured on
    the binding 'WebHttpBinding' ('Anonymous').  Please ensure that the
    SecurityMode is set to Transport or TransportCredentialOnly. 
    Additionally, this may be resolved by changing the authentication
    schemes for this application through the IIS management tool, through
    the ServiceHost.Authentication.AuthenticationSchemes property, in the
    application configuration file at the 
    element, by updating the ClientCredentialType property on the binding,
    or by adjusting the AuthenticationScheme property on the
    HttpTransportBindingElement.</p>
  </blockquote>
  
  <p><strong>UPDATE 2</strong>: The authentication has been set in the following way:</p>
  
  <p>Application Pool:</p>
  
  <ul>
  <li>Identity = NetworkService</li>
  </ul>
  
  <p>Web Site:</p>
  
  <ul>
  <li>Anonymous Authentication = disabled</li>
  <li>ASP.NET Authentication = enabled</li>
  <li>Windows Authentication = enabled</li>
  </ul>
  
  <p>WCF Application:</p>
  
  <ul>
  <li>Anonymous Authentication = disabled</li>
  <li>ASP.NET Authentication = enabled</li>
  <li>Windows Authentication = enabled</li>
  </ul>