【发布时间】:2012-02-12 04:02:41
【问题描述】:
我有一个 WCF 服务装饰有:
[OperationBehavior(Impersonation = ImpersonationOption.Allowed)]
我想在 Web.Config 中配置将用于在服务调用期间模拟的用户凭据。用户是 windows 域用户(凭据为:域\用户名和密码) 这是我的配置:
<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>
我得到错误:
合同操作“方法名称”需要 Windows 身份才能自动模拟。代表调用者的 Windows 身份不是由合约“合约名称”、“http://tempuri.org/”的绑定(“BasicHttpBinding”、“http://tempuri.org/”)提供。
这是预期的,因为用户凭据未在任何地方指定。问题是:我应该把凭证放在哪里? 将它们放在 system.web/identity 中不起作用。我认为 WCF 需要单独配置它们。在哪里?
【问题讨论】:
标签: .net wcf iis impersonation