c# - 未经客户端身份验证方案 NTLM 授权

标签 c# wcf web-services windows-server-2008

我从调用 WCF 服务的 ASPX 页面收到以下错误。

The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM'.

我处于负载平衡的 Web 服务器环境中,当客户端 ASPX 页面访问 < 上的 WCF 服务(也在负载平衡的 Web 服务器上)时才会出现错误em>相同服务器。

例如:
服务器 A 上的 ASPX 页面 -> 服务器 B 上的 WCF 服务 = 没有问题。
服务器 B 上的 ASPX 页面 -> 服务器 C 上的 WCF 服务 = 没有问题。
服务器 B 上的 ASPX 页面 -> 服务器 B 上的 WCF 服务 = 上面的错误。

服务器是 IIS 7.5,WCF 服务当前配置为使用匿名和 Windows 身份验证作为网络服务帐户运行。

这和环回保护有什么关系吗?目前,我无法在应用程序和服务托管在同一台计算机上的单个服务器环境中复制这些结果。

以下是我对 ASPX 页面和服务的绑定(bind):

客户:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_Imyservice">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Ntlm" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://loadbalancedserver/myservice/myservice.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Imyservice"
        contract="myservice.Imyservice" name="BasicHttpBinding_Imyservice" />
    </client>
  </system.serviceModel>

WCF 服务:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpEndpointBinding">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Ntlm" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="myservice.Service.myservice">
        <endpoint address="" bindingNamespace="http://services.company.net/myservice"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpointBinding"
          contract="myservice.Imyservice" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>  

最佳答案

如果有人遇到此问题,那是由于 IIS 环回问题造成的。注册表修复来自 https://social.technet.microsoft.com/wiki/contents/articles/37337.disable-loopback-check-in-iis.aspx成功了。

关于c# - 未经客户端身份验证方案 NTLM 授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12717828/

相关文章:

c# - 如何响应 Windows 服务的状态变化?

asp.net-mvc-3 - 用于 API 访问的 WCF 或 Asp.Net MVC?

c# - WCF DataContract - 无法返回复杂类型

c# - .NET 库绘制路线避开障碍物

c# - 使用列表集中管理类型映射?

c# - 无法在 UWP 的 Windows 运行时组件中访问我的项目中的方法和类

c# - 使用 C# 异步调用 WCF?

wcf - Silverlight客户端身份不总是传递到服务器吗?

javascript - 在 Angular JS 的 uri 参数中使用 'slash' 字符使用 Restful 服务

PHP SoapClient __getLastRequest 和 __getLastRequestHeaders 调用成功返回 NULL