gpt4 book ai didi

wcf - ExtendedProtectionPolicy.PolicyEnforcement 值不匹配。 IIS 的值为 WhenSupported,而 WCF 传输的值为 Never

转载 作者:行者123 更新时间:2023-12-04 18:42:44 24 4
gpt4 key购买 nike

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

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

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

    <binding name="webHttpBindingWindows">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm"></transport>
</security>
</binding>

和:
   <binding name="webHttpBindingWindows">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"></transport>
</security>
</binding>

有无:
<extendedProtectionPolicy policyEnforcement="WhenSupported"></extendedProtectionPolicy>

但我得到了这个异常(exception):

The extended protection settings configured on IIS do not match the settings configured on the transport. The ExtendedProtectionPolicy.PolicyEnforcement values do not match. IIS has a value of WhenSupported while the WCF Transport has a value of Never.



有谁知道如何解决它?

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

谢谢,
纳夫塔利。

最佳答案

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

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

  • IIS 扩展保护 应该转off . 内核模式认证应该是 enabled .
  • Web 配置文件的两个更改:
  • <transport clientCredentialType="Ntlm"></transport>
  • 服务配置内部<endpoint address="mex" … />位于 address="rest" 之前
  • 在 global.asax 授权实现中,我在处理 REST 请求时删除了 cookie 的使用:

  • public void WindowsAuthentication_OnAuthenticate(object sender, WindowsAuthenticationEventArgs args)

    现在它就像忍者一样工作!

    关于wcf - ExtendedProtectionPolicy.PolicyEnforcement 值不匹配。 IIS 的值为 WhenSupported,而 WCF 传输的值为 Never,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21556183/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com