【发布时间】:2015-11-24 12:47:23
【问题描述】:
我们使用 IIS 7.5 托管我们的 Intranet 应用程序,这些应用程序配置为使用 Windows 身份验证。
在其中一个应用程序中,我有一个正在尝试托管/调用的 WCF 服务。这必须具有匿名身份验证,因此我可以使用以下设置托管它:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingOverSslAnonymous">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="myServiceBehaviour"
name="xxx.yyy.Web.Mvc.Client.Services.MyService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingOverSslAnonymous" name="BasicHttpEndpoint" contract="xxx.yyy.Wcf.IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
但是,尽管服务器被配置为允许匿名身份验证并禁用 Windows 身份验证,但我得到的只是以下异常消息:
HTTP 请求未经客户端身份验证方案授权 '匿名的'。从服务器收到的身份验证标头是 ''
注意空的身份验证标头。谷歌搜索是徒劳的,因为所有响应都在引号中包含某些内容(尽管使用了短语搜索运算符)。
这是基于我的客户端,它具有以下配置:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpoint">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://xxx.local/xxx.yyy.Web.Mvc.Client/services/MyService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpoint"
contract="MyService.IMyService" name="BasicHttpEndpoint" />
</client>
</system.serviceModel>
在浏览器中打开 Windows 身份验证工作正常,但我不想发送凭据。
就好像 WCF 忽略了我的 IIS 配置:
- 匿名身份验证
- 假冒
- 基本身份验证
- 表单身份验证
- Windows 身份验证
为什么会这样?
有趣的是,将 test.txt 文件放到同一个文件夹中可以很好地使用匿名设置。好像这只影响 WCF。
【问题讨论】:
标签: wcf authentication iis iis-7.5