WCF security problems with named pipes

后端 未结 2 1468
日久生厌
日久生厌 2021-01-22 13:44

I have a slightly complicated setup that, of course, works fine in XP, but chokes on Windows 7. It may seem like madness, but it made sense at the time!

I have a WPF app

相关标签:
2条回答
  • 2021-01-22 14:06

    The applications (WPF/Console) are creating locally scoped named pipes (this happens by default when they are unable to create globally scoped pipes). My guess is that they can communicate with each other because they can see each others named pipes because they are running under the same account.

    The windows service has higher privileges and can therefore create a globally scoped named pipe for the client applications to see.

    You can check out a discussion on Christian Weyer's Blog.

    0 讨论(0)
  • 2021-01-22 14:08

    This question has been asked several times previously on SO. For example, see Connecting via named pipe from windows service to desktop app

    The problem is that your user session applications don't possess the SeCreateGlobalPrivilege security privilege necessary to allow them to create objects in the global kernel namespace visible to other sessions, but only in the local namespace which is only visible within the session. Services, on the other hand, which run with this privilege by default, can do so.

    It is not the named pipe object itself which is constrained to the local namespace in this way, but another named kernel object, a shared memory section, on which the WCF named pipe binding relies in order to publish to its clients the actual name of the pipe, which is a GUID which changes each time the service is started.

    You can get round this constraint by reversing the roles - make the windows service application the WCF Service, to which your user session apps connect. The windows service has no problem publishing its service to your session. And connecting things up this way round makes more sense because the windows service is always running, whereas your session and its apps comes and goes as you log in and out. You'll want to define the service with a duplex contract, so that once the connection is established, the essential flow of communication over the WCF service can still happen in the same direction you originally intended.

    0 讨论(0)
提交回复
热议问题