• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 319
  • Last Modified:

cross users named pipes

I tried running a simple-client server
program using named pipes, when different users are
running the client and the server.
I got ACCESS_DENIED error when the client used CreateFile
to connect to the pipe.
Should the server change the sercurity attributes of the
named pipe ?
I created the pipe with default security attributes.

Could you tell me exactly how to allow a client to
connect to a named pipe (a short working piece of code
will be welcomed).

thanks in advance,
Avi.
0
kavas
Asked:
kavas
  • 2
1 Solution
 
lortegaCommented:
both users must have running windows NT, windows 95 just can't create a server side of a named pipe...
0
 
kavasAuthor Commented:
Both of my client and server are running windows NT.

0
 
kavasAuthor Commented:
Adjusted points to 150
0
 
stefanrCommented:
Create a NULL DACL, that will allow all access to the named pipe:

PSECURITY_DESCRIPTOR pSecurityDescriptor = PSECURITY_DESCRIPTOR(new BYTE[SECURITY_DESCRIPTOR_MIN_LENGTH]);

::InitializeSecurityDescriptor(pSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION);
::SetSecurityDescriptorDacl(pSecurityDescriptor, TRUE, NULL, FALSE);

SECURITY_ATTRIBUTES SecurityAttributes = { 0 };

SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
SecurityAttributes.lpSecurityDescriptor = pSecurityDescriptor;
SecurityAttributes.bInheritHandle = FALSE;

HANDLE hFile =
      ::CreateFile(
         sPipeName,                 // LPCTSTR lpFileName: pointer to name of the file
         dwDesiredAccess,           // DWORD dwDesiredAccess: access (read-write) mode
         dwShareMode,               // DWORD dwShareMode: share mode
         &SecurityAttributes, // LPSECURITY_ATTRIBUTES lpSecurityAttributes: pointer to security attributes
         dwCreationDisposition,     // DWORD dwCreationDisposition: how to create
         dwFlagsAndAttributes,      // DWORD dwFlagsAndAttributes: file attributes
         NULL                       // HANDLE hTemplateFile: handle to file with attributes to copy
      );

delete pSecurityDescriptor;

if (INVALID_HANDLE_VALUE == hFile)
   return FALSE;

0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now