I have a WCF service decorated with:
[OperationBehavior(Impersonation = ImpersonationOption.Allowed)]
I'd like to configure in Web.Config credentials of the user that will be used to impersonate during service invocation. The user is windows domain user (credentials are: domain\username and password) Here is my config:
<behaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceAuthorization impersonateCallerForAllOperations="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="httpBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="MetadataBehavior" name="<serviceName>">
<endpoint address="/" binding="basicHttpBinding" contract="<service contract>" bindingConfiguration="httpBinding"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="<service url>"/>
</baseAddresses>
</host>
</service>
</services>
I get error:
The contract operation 'method name' requires Windows identity for automatic impersonation. A Windows identity that represents the caller is not provided by binding ('BasicHttpBinding','http://tempuri.org/') for contract 'contract name','http://tempuri.org/'.
That is expected as the user credentials are not specified anywhere. The question is: Where should I place the credentials? Placing them in system.web/identity doesn't work. I think that WCF needs them to be configured separately. Where?