简体   繁体   English

在具有impersonate = true的网站中使用WCF的net.pipe

[英]Using WCF's net.pipe in a website with impersonate=true

I'm trying to use WCF named pipes in a web site, and it's failing with errors: 我正在尝试在网站中使用WCF命名管道,但由于错误而失败:

There was no endpoint listening at net.pipe://localhost/mypipename that could accept the message. 在net.pipe:// localhost / mypipename上没有侦听终结点的端点可以接受该消息。 This is often caused by an incorrect address or SOAP action. 这通常是由不正确的地址或SOAP操作引起的。 See InnerException, if present, for more details. 有关更多详细信息,请参见InnerException(如果存在)。

and the InnerException: 和InnerException:

The pipe name could not be obtained for net.pipe://localhost/mypipename.

and there is another inner exception giving an access denied message. 还有另一个内部异常给出access denied消息。

My web site is using impersonation, and looking around the internet, this seems to be relevant, but I don't know how to fix it. 我的网站正在使用模拟功能,并且环顾互联网,这似乎很有意义,但是我不知道如何解决。

Does anyone have any ideas? 有人有什么想法吗?

Thanks Matt 谢谢马特

The standard WCF NetNamedPipesBinding creates a randomly-generated pipe name when the service starts up, and also a kernel shared memory object which the WCF client-side channel stack has to consult to find out the name of the pipe. 服务启动时,标准的WCF NetNamedPipesBinding将创建随机生成的管道名称,还创建一个内核共享内存对象,WCF客户端通道堆栈必须参考该内核共享内存对象以找出管道的名称。

Using impersonation on your web site means that the security context from which your WCF service is being invoked has a logon token (the impersonation token) which includes membership of the NETWORK USERS group. 在您的网站上使用模拟意味着从中调用WCF服务的安全上下文具有登录令牌(模拟令牌),其中包括NETWORK USERS组的成员身份。

When the service listener starts up, the WCF binding creates an Access Control List (ACL) on both the named pipe itself, and on the shared memory object where the pipe name is published. 服务侦听器启动时,WCF绑定将在命名管道本身以及发布管道名称的共享内存对象上创建访问控制列表(ACL)。 Both of these ACLs deny access to the NETWORK USERS group. 这两个ACL均拒绝访问NETWORK USERS组。 Thus your web site, impersonating the remote user, is denied access to the shared memory object before it can even discover the pipe name. 因此,冒充远程用户的网站甚至在发现管道名称之前就无法访问共享内存对象。 Even if it found out the pipe name some other way, it would still be denied access to the pipe. 即使以其他方式找到了管道名称,也仍然无法访问该管道。

Everything works when you remove impersonation, because now the service is being invoked in the security context of the web application worker process, whose logon token does not have membership of the NETWORK USERS group - it is a local logon. 删除模拟后,一切正常,因为现在正在Web应用程序工作进程的安全上下文中调用该服务,该服务的登录令牌没有NETWORK USERS组的成员身份-它是本地登录。

More details at http://blogs.charteris.com/blogs/chrisdi if you're interested. 如果您有兴趣,请访问http://blogs.charteris.com/blogs/chrisdi ,以获取更多详细信息。 I show how the ACLs can be adjusted, and in principle this approach could be used to grant access to remote users, but I don't recommend this. 我展示了如何调整ACL,并且原则上可以使用这种方法向远程用户授予访问权限,但是我不建议这样做。

If you're getting this particular exception, it typically means that your service is not running. 如果您遇到此特定异常,则通常意味着您的服务未运行。 I see that you use localhost in the URL. 我看到您在URL中使用localhost I just want to make sure that the host and the service are running on the same machine. 我只想确保主机和服务在同一台计算机上运行。 WCF does not allow communication across machines with this binding. WCF不允许使用此绑定在计算机之间进行通信。

When I get this message, usually I check and see that I forgot to start the service, thus, there is no endpoint listening. 当我收到此消息时,通常会检查并发现我忘记启动该服务,因此没有端点监听。 Please check that your service is actually still running and hasn't crashed at the time that the exception is thrown. 请检查您的服务实际上是否仍在运行,并且在引发异常时没有崩溃。 If that doesn't fix the problem, please post your progress and I can make more suggestions. 如果仍不能解决问题,请发表您的进度,我会提出更多建议。

我通过使IIS终结点解决了该问题,该终结点最终使网络管道从可用状态变为匿名用户,这意味着没有假冒行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM