【问题标题】:WCF service with WsHttpBinding & windows authentication failing with anonymous access error带有 WsHttpBinding 和 Windows 身份验证的 WCF 服务因匿名访问错误而失败
【发布时间】:2015-02-03 07:27:13
【问题描述】:

美好的一天。我在 WCF 中编写了一个使用消息级安全性的服务,该服务设置为使用 Windows 身份验证。相关配置如下图:

<wsHttpBinding>
    <binding name="WsHttpBinding" closeTimeout="00:30:00" openTimeout="00:30:00"
      receiveTimeout="00:30:00" sendTimeout="00:30:00" maxBufferPoolSize="2147483647"
      maxReceivedMessageSize="2147483647">
      <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"
        maxBytesPerRead="2147483647" />
      <security mode="Message">
        <message clientCredentialType="Windows" establishSecurityContext="true" />
      </security>
    </binding>
</wsHttpBinding>

调用客户端的开发人员请求使用这些详细信息配置我的服务。不幸的是,我也无权访问客户端绑定的配置,但我只能假设它配置正确,因为它使用的其他服务正在运行。

该服务通过 IIS 托管,作为默认网站下的应用程序。服务应用程序的身份验证设置为 Windows,匿名身份验证已关闭。它也没有绑定 SSL 证书。

从客户端调用服务时,日志中报如下错误: HTTP 请求未经客户端身份验证方案“匿名”授权。从服务器收到的身份验证标头是“协商,NTLM”。

任何解决此问题的帮助将不胜感激。

其他信息

为了找到解决方案,我拼凑了一个 WinForms 测试客户端来调用该服务。客户端绑定配置如下:

<wsHttpBinding>
    <binding name="WSHttpBinding_IEAIEndpointService" closeTimeout="00:10:00"
      openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
      maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
        <security mode="Message">
          <message clientCredentialType="Windows" establishSecurityContext="true" />
        </security>
    </binding>
</wsHttpBinding>

在使用客户端代理进行调用之前,我有以下代码来设置我希望服务进行身份验证的 Windows 用户帐户:

client.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("Username", "Password", "DOMAIN");

即使使用此配置,我仍然收到上述错误。

【问题讨论】:

    标签: c# wcf authentication


    【解决方案1】:

    IIS 身份验证是传输安全性。您的客户要求消息安全,因此您需要禁用它。消息安全将由 WCF 处理,而不是 IIS。

    【讨论】:

    • 清晰简洁的答案,谢谢。找不到能说得这么清楚的解释。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-21
    • 1970-01-01
    • 2012-10-15
    相关资源
    最近更新 更多