Search code examples
c#windowssecuritypipenamed

Named Pipe security problem on some Windows clients


I'm using named pipe for a communication inside a C# process. The software is used on different Windows PCs. On some PCs my software is working and on some I get the following error:

"Some or all identity references could not be translated."

I can't find any log entry in the Windows Event Log nor in the Windows Firewall log.

Thats the code I'm using:

PipeSecurity pipeSecurity = new PipeSecurity();
pipeSecurity.AddAccessRule(new PipeAccessRule("Users", PipeAccessRights.ReadWrite | PipeAccessRights.CreateNewInstance, AccessControlType.Allow));

Solution

  • The error "Some or all identity references could not be translated." means that one those machines your group name "Users" did not exist. These groups might have a different name on different machines, e.g. on machines with a non-english OS language.

    Try using security identifiers (sid) instead:

    var sid = new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null);
    var usersAccount = sid.Translate(typeof(NTAccount));
    pipeSecurity.AddAccessRule(new PipeAccessRule(usersAccount, ...