1

I want to use namedpipeserver/client to communicate between two applications on two computers in a network. This network is a SOHO architecture, so security is of a lesser concern, we're just currently trying to get the system up and running.

I have written an Taskbar Application that opens up a server (on computer A) and a winform application that connects to the server (on computer B). Running both on the same computer gives me a functional interaction.

Trying it on two machines gives the error "System.IO.IOException: "Der Benutzername oder das Kennwort ist falsch." (in english: "The user or password are incorrect")

I have already searched high and low and found a few interesting articles such as:

Setting named pipe security in a Domain

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

NamedPipeClientStream can not access to NamedPipeServerStream under session 0

Named Pipes Across Network Gives "The user name or password is incorrect"

I changed my security settings for the server accordingly:

        PipeSecurity pipeSa = new PipeSecurity();
        // Set the pipesecurity
        pipeSa.SetAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
                        PipeAccessRights.ReadWrite, AccessControlType.Allow));
        // Alternative with "everyone"
        // pipeSa.SetAccessRule(@"Jeder", PipeAccessRights.ReadWrite, AccessControlType.Allow));

        serverPipeStream = new NamedPipeServerStream(
            pipeName,
            PipeDirection.InOut,
            NamedPipeServerStream.MaxAllowedServerInstances,
            PipeTransmissionMode.Message,
            PipeOptions.Asynchronous,
            10,
            10,
            pipeSa);

Alas without success. I also checked the port settings for the firewalls on both machines and cannot connect. Any hints on how to troubleshoot this issue further or what I am doing wrong would be greatly appreciated.

JoeyD
  • 277
  • 3
  • 14
  • https://stackoverflow.com/questions/6120124/how-to-use-named-pipes-over-network Does this solve your problem? – KC Wong Aug 27 '18 at 07:00
  • Not really, I wasn't able to relate the information. If it is the server name: I tried the network name as well as an IP, to no success. – JoeyD Aug 28 '18 at 09:52

1 Answers1

0

try with:

var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
var account = (NTAccount)sid.Translate(typeof(NTAccount));
var rule = new PipeAccessRule(
    account.ToString(), 
    PipeAccessRights.FullControl, 
    AccessControlType.Allow);
var securityPipe = new PipeSecurity();
securityPipe.AddAccessRule(rule);

var pipeserver = new NamedPipeServerStream(
    Name, 
    PipeDirection.InOut, 
    NamedPipeServerStream.MaxAllowedServerInstances, 
    PipeTransmissionMode.Message, 
    PipeOptions.None, 
    0, 
    0, 
    securityPipe)

Work fine for me.

Francois
  • 21
  • 1