Named pipe client unable to connect to server running as Network Service

前端 未结 2 1567
清酒与你
清酒与你 2021-01-11 23:11

I have a service running under the Network Service account. The service just sets up a named pipe and listens for connections:

NamedPipeServerStream listenin         


        
相关标签:
2条回答
  • 2021-01-11 23:45

    Pipe server is created with the default service DACL so that only the administrator or system user can connect to the pipe. You need to set the pipe server with proper access rules to make all client connection to succeed. Below is the code to set the access rule to access everyone to access the pipe:

        PipeSecurity pipeSa = new PipeSecurity(); 
        pipeSa.SetAccessRule(new PipeAccessRule("Everyone", 
                        PipeAccessRights.ReadWrite, AccessControlType.Allow)); 
        listeningPipe.SetAccessControl(pipeSa);
    

    It always better to define only a minimal set of users to access the pipe server to make it secure.

    0 讨论(0)
  • 2021-01-12 00:06

    I'm not allowed to comment, but I want to point out that dvansanth's answer is correct depending on the OS language. When the OS language isn't English, the "Everyone" group probably won't exist.

    I've solved it like this:

    PipeSecurity pipeSa = new PipeSecurity();
    pipeSa.SetAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null), 
                    PipeAccessRights.ReadWrite, AccessControlType.Allow)); 
    listeningPipe.SetAccessControl(pipeSa);
    

    Note this is for "Authenticated users" not "Everyone"

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