wcf - 在 NetNamedPipe 服务端点的端点地址上设置 SPN

标签 wcf netnamedpipebinding spn

我收到“net.pipe://localhost 没有端点监听”错误,如其他地方所述,但我似乎找不到真正的答案。

这是问题的一个很好的标识: http://kennyw.com/indigo/102

When using WCF, Windows authentication is performed through SSPI-Negotiate, which in most cases will select Kerberos as the actual authentication mechanism. However, if the target SPN passed to SSPI is a well formed SPN for the local computer account (e.g. host/[dns machine name]) then Negotiate will use NTLM (loopback optimization) and the access token will not have the Network SID (and therefore will be usable with NetNamedPipes).

但它没有告诉我如何解决该问题。我正在以编程方式创建端点。

var binding = new NetNamedPipeBinding();
binding.Security.Mode = NetNamedPipeSecurityMode.Transport;
binding.Security.Transport.ProtectionLevel = ProtectionLevel.EncryptAndSign;

var id = EndpointIdentity.CreateSpnIdentity("host/" + Environment.MachineName);
var endpointAddress = new EndpointAddress(new Uri(serviceClientUrl), id);

var client = new ServiceClient(binding, endpointAddress);

我猜测我的问题出在 CreateSpnIdentity 中,但我不确定要使用什么值。

其他信息: 详细说明这一点以获得更多背景。 Wcf 服务作为 Windows 服务托管在 NetworkService 帐户下运行(我尝试过本地系统)。该服务是使用默认的 NetNamedPipeBinding 构造函数创建的:

host.AddServiceEndpoint(typeof(IService), new NetNamedPipeBinding(), "ServiceName");

我创建了一个使用此服务的 SharePoint Web 部件。更重要的是,如果 SharePoint 站点设置为基于表单的身份验证,或者在 Windows 身份验证下的 URL 中仅使用计算机名称,则不会出现任何问题。 如果 Windows 身份验证下的 url 使用完全限定的计算机名称,我会收到上述错误。

我很确定这与文章中描述的 NTLM Kerberos 问题有关,但我不确定如何解决它。

最佳答案

在客户端设置端点标识不会对您有帮助,因为问题在于执行客户端代码的安全上下文,而不是端点的配置。如KennyW explains ,如果您使用计算机的完整域名访问 SharePoint 应用程序,则将通过 Kerberos 获取 Web 服务器进程中的模拟 token (在 Windows 身份验证下提供您的 SharePoint 用户身份),并具有 NETWORK USERS 组的成员身份。如果您仅使用计算机名称,Kenny 提到的优化会通过 NTLM 为您获取登录 token ,该 token 不在 NETWORK USERS 组中,因此不会被 WCF 放置在管道和共享内存对象上的 ACL 拒绝访问服务器在其中发布实际的管道名称。

错误There was no endpoint Listening at net.pipe://localhost...并不一定意味着没有WCF服务在这样的命名管道端点上监听:它也可以(在这种情况下确实)意味着虽然有一个,但您没有足够的访问权限来了解它,因为您有远程登录。

关于wcf - 在 NetNamedPipe 服务端点的端点地址上设置 SPN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3729346/

相关文章:

c# - 通过 Internet 使用 wcf 服务

c# - 如何正确设置 NetNamedPipe 的安全性?

java /SPNEGO : Unwanted SPN canonicalization?

Kerberos - SPN 和 key 表

Kerberos 和多个 SPN

wcf - 在 DataContract Serializer Metadata 中包含 XML 注释

javascript - 使用Ext.js从WCF获取数据 "Network Error 400 Bad Request"

c# - 类型 'System.Web.HttpInputStream' 未标记为可序列化

c# - NetNamedPipeBinding 安全吗?

具有 netNamedPipeBinding 性能不佳的 WCF