title: How to require impersonation on a WCF service and set credentials from within the service?
body: <p>I have a WCF service in which I am trying to set up a set of credentials so that they will be used not only for the service, but also for all subsequent operations on the NAS.</p>
  
  <p>I currently have set the attribute <code>[OperationBehavior(Impersonation = ImpersonationOption.Required)]</code> on the method and have set <code>&lt;identity impersonate="true" userName="DOMAINUSER" password="PASSWORD"/&gt;</code> within the service web.config.  Since this is an internal service and I don't want to require special credentials from the consumer I would like to use <code>&lt;basicHttpBinding&gt;</code> with <code>&lt;security mode="None"&gt;</code>.  The issue is that when set this way I receive the error:</p>
  
  <pre><code>The contract operation requires Windows identity for automatic impersonation. 
  A Windows identity that represents the caller is not provided by
  binding 'BasicHttpBinding' for contract.
  </code></pre>
  
  <p>Set as above, the <code>WindowsIdentity.GetCurrent().Name</code> returned is NT AUTHORITY\NETWORK SERVICE despite having the impersonation directive set in the web.config.  It seems to want the credentials passed from the consumer/client rather than set from within the service. </p>
  
  <p>Is it possible to have the impersonation contained completely within the service rather than relying upon the consumer to send the credentials?</p>
  
  <p>Thanks!</p>