I have a client and a NamedPipe server. The client and the server run on distinct Windows services. On the same machine the connection works perfectly. But when attempting to access the server from another machine, an exception of type UnauthorizedAccessException is thrown (access is denied). I researched several posts and included AccessRules on the server, but it did not work. The client machine user does not exist on the server machine. Is there a specific / AccessRule setting for this case? Does anyone know the solution?
Server:
private NamedPipeServerStream _setupServer;
PipeSecurity ps = new PipeSecurity();
//Everyone
ps.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow));
//Users
ps.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow));
//SYSTEM
ps.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null), PipeAccessRights.FullControl, AccessControlType.Allow));
using (_setupServer = new NamedPipeServerStream(typeof(ISetupClient).Name, PipeDirection.InOut, NamedPipeServerStream.MaxAllowedServerInstances, PipeTransmissionMode.Message, PipeOptions.None, 4024, 4024, ps))
{
this._setupServer.WaitForConnection();
//...
}
Client:
string ipServidor = "192.168.40.155";
using (var setupClient = new NamedPipeClientStream(ipServidor, typeof(ISetupClient).Name, PipeDirection.InOut, PipeOptions.None))
{
int timeOut = 10;
setupClient.Connect(timeOut);
//...
}