我从调用 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/