ExtendedProtectionPolicy.PolicyEnforcement值不匹配.IIS的值为WhenSupported,而WCF Transport的值为Never

nhe*_*hko 5 security rest wcf windows-authentication iis-7.5

我正在处理处理WCF REST服务的安全网站.一切都很好,直到我开始保护我的网站.我将身份验证模式从匿名更改为Windows身份验证,并在global.asax文件中实现自动化.

对于按MVC架构设计并使用内部服务的网站,一切都按预期工作但REST API运行不正常.

我已将安全配置添加到web.config绑定部分,如下所示:

    <binding name="webHttpBindingWindows">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm"></transport>
      </security>
    </binding>
Run Code Online (Sandbox Code Playgroud)

和:

   <binding name="webHttpBindingWindows">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" proxyCredentialType="Windows"></transport>
      </security>
    </binding>
Run Code Online (Sandbox Code Playgroud)

有和没有:

<extendedProtectionPolicy policyEnforcement="WhenSupported"></extendedProtectionPolicy>
Run Code Online (Sandbox Code Playgroud)

但我得到了这个例外:

IIS上配置的扩展保护设置与传输上配置的设置不匹配.ExtendedProtectionPolicy.PolicyEnforcement值不匹配.IIS的值为WhenSupported,而WCF Transport的值为Never.

有没有人知道如何解决它?

如果我将IIS上的扩展保护设置为关闭,我根本无法进行身份验证.(我有浏览器弹出窗口,但无法使用任何用户帐户登录.)

谢谢,Naftali.

nhe*_*hko 6

最终我得到了这个问题的解决方案:

这些变化发生在三个不同的地方:

  1. 应该转向IIS 扩展保护off.内核模式身份验证应该是enabled.
  2. Web配置文件有两处更改:

    1. <transport clientCredentialType="Ntlm"></transport>

    2. 服务配置里面<endpoint address="mex" … />不是address="rest"

  3. 在global.asax授权实现中,我在以下处理REST请求时删除了cookie的使用:
public void WindowsAuthentication_OnAuthenticate(object sender, WindowsAuthenticationEventArgs args)
Run Code Online (Sandbox Code Playgroud)

现在它像忍者一样工作!