Solved

cross users named pipes

Posted on 1998-11-26
4
302 Views
Last Modified: 2013-12-03
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
Comment
Question by:kavas
  • 2
4 Comments
 
LVL 2

Expert Comment

by:lortega
ID: 1416379
both users must have running windows NT, windows 95 just can't create a server side of a named pipe...
0
 

Author Comment

by:kavas
ID: 1416380
Both of my client and server are running windows NT.

0
 

Author Comment

by:kavas
ID: 1416381
Adjusted points to 150
0
 
LVL 3

Accepted Solution

by:
stefanr earned 150 total points
ID: 1416382
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question