C# programs communicating by named pipes as service between 2 hosts

914 Views Asked by At

How can 2 C# programs communicate with each other by named pipes.

If I run the program under a administrator account with elevated rights everything works.
I need to run this programs as a service with the account 'Local System' but then I have no network access.

Situation :

  • Server : 1 program runs as a service on a Windows Server 2012 Datacenter
  • Client : 1 program runs as a service on a client Windows 7, 8.1 or 10

On the server

  • I put the name of named pipe in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters[NullSessionPipes]
    Restart the the service LanmanServer

In the server program I create the pipe as follow

PipeSecurity psobj = new PipeSecurity();
psobj.AddAccessRule(new PipeAccessRule("EveryOne", PipeAccessRights.FullControl, AccessControlType.Allow));
NamedPipeServerStream requestpipe = new NamedPipeServerStream(REQUESTPIPENAME, PipeDirection.InOut, numThreads, PipeTransmissionMode.Byte, 
                            PipeOptions.Asynchronous, 2048, 2048, psobj);

In the client program I connect to the named pipe as follow:

NamedPipeClientStream pipeClient = new NamedPipeClientStream(SERVER, REQUESTPIPENAME, PipeDirection.InOut, PipeOptions.WriteThrough)

I simulated also the situation between 2 Windows 7 machines (1 physical and 1 virtual, not bridged). Here I tried some options in :

  • Network access: Restrict anonymous access to Named Pipes and shares => Disabled
  • Network access: Allow LocalSystem NULL session fallback => Enabled

Any suggestions ?

0

There are 0 best solutions below