var pipeName = "testpipe"; var pipeServer = new NamedPipeServerStream(pipeName, PipeDirection.InOut); var pipeSecurity = pipeServer.GetAccessControl(); Console.WriteLine(pipeSecurity.GetOwner(typeof(NTAccount)));
var pipeName = "testpipe"; var pipeServer = new NamedPipeServerStream(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous); var pipeSecurity = pipeServer.GetAccessControl(); var rule = new PipeAccessRule("NETWORK SERVICE", PipeAccessRights.ReadWrite, System.Security.AccessControl.AccessControlType.Allow); pipeSecurity.AddAccessRule(rule); pipeServer.SetAccessControl(pipeSecurity);This example creates a new NamedPipeServerStream object with the pipe name "testpipe", and sets the transmission mode to byte and the options to asynchronous. It then retrieves the security descriptor for the pipe server using the GetAccessControl method, adds a new access rule that allows the NETWORK SERVICE account to read and write to the pipe, and sets the updated security descriptor using the SetAccessControl method. The package library for the NamedPipeServerStream class is System.IO.Pipes.