title: Impersionation like in ASP.NET for WCF Service
body: <p>I've got a WebService with ASP.NET sites and WCF services in the same web.config. Until now, I was able to use the ASP.NET impersionation in the WCF services by setting</p>
  
  <pre><code>&lt;system.web&gt;
      &lt;compilation targetFramework="4.0" debug="false"/&gt;
      &lt;!-- switch custom errors of--&gt;
      &lt;identity impersonate="true"/&gt;
      &lt;customErrors mode="Off"/&gt;
  &lt;/system.web&gt;
  </code></pre>
  
  <p>However, now (for other reasons-> Cookieless Session state for the ASP.NET part) I have to set the </p>
  
  <pre><code>aspNetCompatibilityEnabled="true" 
  </code></pre>
  
  <p>option to false. With this I loose the ASP.NET impersionation for the WCF services. 
  One of my WCF services needs impersionation for IO operations on the server...
  I would like to know how to get the same impersionation I had before by directly defining it on the WCF service configuration.</p>
  
  <p>What I have tried (unsucessfully) is to set </p>
  
  <pre><code>[OperationBehavior(Impersonation = ImpersonationOption.Required)]
  </code></pre>
  
  <p>on the implementation of the methods in the WCF service and then specifying </p>
  
  <pre><code>&lt;endpoint address="" binding="wsHttpBinding" contract="IService"&gt;
    &lt;identity&gt;
      &lt;servicePrincipalName value="HOST/YourMachineName" /&gt;
      &lt;dns value="" /&gt;
    &lt;/identity&gt;
  &lt;/endpoint&gt;
  </code></pre>
  
  <p>in the web.config (obviously with the correct values for my service), as described in <a href="http://msdn.microsoft.com/en-us/library/ff650591.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ff650591.aspx</a>.</p>
  
  <p>However, the WCF service can not be called anymore after this... It tells me that the WsHttpBinding does not offer an identity for the contract.</p>
  
  <p>Am I missing something important?</p>
  
  <p>Edit: Translation of the error message:</p>
  
  <p>: The contract operation '{0}' requires Windows identity for automatic impersonation. A Windows identity that represents the caller is not provided by binding ('{1}','{2}') for contract ('{3}','{4}'.</p>
  
  <p>(The original error message was german...)</p>