【发布时间】:2017-08-16 21:14:52
【问题描述】:
问题是我无法使用 wsHttpBinding 获得 Windows 身份验证。
这是配置:
<services>
<service name="WcfService1.Service1">
<endpoint address="" bindingConfiguration="testbinding" contract="WcfService1.IService1" binding="wsHttpBinding"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="testbinding">
<security mode="Transport">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
这是尝试调用方法时服务器的响应: HTTP 请求未经客户端身份验证方案“协商”的授权。从服务器收到的身份验证标头是“协商 oXMwcaADCgEBomoEaGBmBgkqhkiG9xIBAgIDAH5XMFWgAwIBBaEDAgEepBEYDzIwMTcwODE2MjA1MjQwWqUFAgMK8G2mAwIBKakOGwxDT1JQLlNBQUIuU0WqGjAYoAMCAQGhETAPGw1jb3JwYXBkbw”。 还有一个内部异常说: "目标主体名称不正确"
我在 IIS 中设置了一个新站点,用于测试目的,启用了 Windows 身份验证并禁用了其他所有功能(我没有进行任何 ASP 模拟/双跳)。 Windows 身份验证的提供程序是 Negotiate、Ntlm。内核模式身份验证已启用。 应用程序池使用 Active Directory 服务帐户运行。 最终的目标是使用 Kerberos 进行身份验证,但由于它甚至不能与 Ntlm 一起使用,所以我还没有开始使用 SPN 和那些让 kerberos 工作的东西。
但是,如果我将应用程序池更改为使用“ApplicationPoolIdentity”而不是 AD 服务帐户运行,它会起作用吗? 我必须使用 AD 服务帐户运行应用程序池。
如果我将配置更改为:
<services>
<service name="WcfService1.Service1">
<endpoint address="" bindingConfiguration="hbinding" contract="WcfService1.IService1" binding="basicHttpsBinding"/>
</service>
</services>
<bindings>
<basicHttpsBinding>
<binding name="hbinding">
<security mode="Transport">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpsBinding>
它工作正常(保留 AD 服务帐户),这是为什么呢? 我不想使用 basicHttpsBinding
我发现客户端配置文件(使用 wcftestclient)与使用 wshttp 时有所不同:
<identity>
<userPrincipalName value="serviceaccount@contoso.com" />
</identity>
这和这个有关系吗? (这里只是胡乱猜测)
端点是 https,Windows Server 2012R2 上的 IIS 8。
【问题讨论】:
标签: c# wcf authentication iis