首页 > 解决方案 > 当 IIS 在域用户身份下运行时,WCF netTcpBinding 失败(SSPI 身份验证失败)

问题描述

netTcpBinding我们有一个 WPF 应用程序,它使用设置为消息和传输安全的安全TransportWithMessageCredential性连接到 WCF 服务。IIS 应用程序池以域用户的身份运行。clientCredentialTypeWindows

上面的设置在本地工作得很好(这意味着 WCF 服务和 WPF 应用程序在同一个盒子上运行)。当 WPF 应用程序在不同的盒子上时,通信失败并出现以下错误:

System.ServiceModel.Security.SecurityNegotiationException:与目标“net.tcp://serv01.domain.local:30128/UsersService”的“net.tcp://serv01.domain.local:30128/UsersService.svc”进行 SOAP 安全协商。 svc' 失败。有关更多详细信息,请参阅内部异常。---> System.ComponentModel.Win32Exception:安全支持提供程序接口 (SSPI) 身份验证失败。服务器可能未在身份为“host/serv01.domain.local”的帐户中运行。如果服务器在服务帐户(例如网络服务)中运行,请将帐户的 ServicePrincipalName 指定为服务器的 EndpointAddress 中的标识。如果服务器在用户帐户中运行,请将帐户的 UserPrincipalName 指定为服务器的 EndpointAddress 中的标识。在 System.ServiceModel。1.GetNextOutgoingMessage(Message incomingMessage, T negotiationState) at System.ServiceModel.Security.IssuanceTokenProviderBase1.DoNegotiation(TimeSpan timeout) --- 内部异常堆栈跟踪结束 ---

盒子之间没有防火墙。此外,当 Web 服务器上的 IIS 使用 LocalService 身份时,应用程序之间的通信工作正常。

什么可能导致问题,我如何确定根本原因?我在事件日志中没有看到任何其他可以提供一些启示的错误消息。

标签: wcfnettcpbinding

解决方案


很难找到答案,但在我的情况下,我需要使用主机的 ServicePrincipalName 注册我的 IIS 身份服务帐户。此页面上提供了答案:http ://www.getshifting.com/wiki/setupn

你需要做的是:

1) 运行命令setspn -l domain\identity_user,其中“ domain\identity_user”是运行 IIS 的用户帐户。一切设置正确后,此命令必须从错误消息中返回 SPN。就我而言 - 修复后 - 它返回:

HOST/SERV01
HOST/SERV01.DOMAIN.LOCAL

2) 如果列表为空,则需要添加这些 SPN。跑:

setspn -A HOST/SERV01 domain\identity_user
setspn -A HOST/SERV01.DOMAIN.LOCAL domain\identity_user

就是这样。


推荐阅读