Solved

cross users named pipes

Posted on 1998-11-26
4
298 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now