3

I am creating a named pipe in windows service running on local system account with security attribute as Intptr.Zero in CreateNamedPipe() method of Windows API.

The problem is that this named pipe is not accessible to the user account running the client application and calling CreateFile() method.

Now I have searched the web and found out that we can change the security attributes but I am not able to do that.

halfer
  • 19,824
  • 17
  • 99
  • 186
Apurva Saxena
  • 448
  • 1
  • 5
  • 13

3 Answers3

3

Finally after hell lot of googling I found out the solution to my problem. I used two more win api methods to set access to user account. the methods are as follows

  1. SetSecurityDescriptorDacl()
  2. InitializeSecurityDescriptor()

for detailed answer you can refer to what i refered... http://www.codeproject.com/KB/threads/CodeFX_IPC.aspx?display=Print

Thanks for your answers....

Apurva Saxena
  • 448
  • 1
  • 5
  • 13
0

I just ran in to this problem myself on Friday. If you are using .net 3.5 or higher see my question on how to set the permissions. using System.IO.Pipes (In summary create a PipeSecurity and add access rules for the users group with read/write permissions.)

Community
  • 1
  • 1
Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431
  • the problem is u have used .net named pipes and im using win api named pipes... can u please provide solution regarding win32 api named pipe security attributes. – Apurva Saxena Aug 16 '10 at 13:26
  • I tried to do my solution with win32 named pipes and was not able to get it to work unfortunatly. Then I found the .net wrapper and it worked. May I ask why you are staying away from the .net version? – Scott Chamberlain Aug 16 '10 at 13:27
  • i used .net wrapper earlier but got disconnection issues in windows services running in local system account. so i switched to win api' – Apurva Saxena Aug 16 '10 at 13:28
0

What exactly are you not able to do, and what have you tried? You have to change the parameter type of the last parameter from IntPtr to ref SECURITY_ATTRIBUTES and pass in the security settings explicitly.

Creating a security descriptor manually in code can get messy. Using the string representation with ConvertStringSecurityDescriptorToSecurityDescriptor makes it a little bit less painfull.

Mattias S
  • 4,748
  • 2
  • 17
  • 18
  • I am new to win API'. Can u please provide me code for the making custom security attributes as when I made a delegate named security attributes and passed it to the last paramenter its giving CA1901 error. – Apurva Saxena Aug 16 '10 at 13:40