使用WsHttpBinding& WCF的WCF服务Windows身份验证失败,出现匿名访问错误

时间:2015-02-03 07:27:13

标签: c# wcf authentication

美好的一天。我在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请求未经授权使用客户端身份验证方案&#39; Anonymous&#39;。从服务器收到的身份验证标题是“Negotiate,NTLM&#39;

我们将非常感谢您解决此问题的任何帮助。

其他信息

为了找到解决方案,我把一个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");

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

1 个答案:

答案 0 :(得分:2)

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

相关问题