locked
Problem with named pipe server in C# and client in native C++ (ACCESS_DENIED)

    Question

  • Hi,

    I'm trying to use IPC between a server application in C# and client application in native C++.

    The IPC is "named pipes".

    The OS is Windows 7.

    It works just fine with C# server and C# client.

    It works fine with native C++ server and native C++ client.

    However, the native C++ client refuses to connect to same C# server. The error code is 5 (ERROR_ACCESS_DENIED).

    Both security descriptors are NULL.

    Does anyone here uses such combination or can shed some light on this issues?

    Thanks!

     

     

    Thursday, May 19, 2011 11:20 PM

Answers

  • The default security descriptor should give the creator and administrators full control. If running both server and client as administrator, there should not be any security barrier between the two.

    There are some discussions of access denied error occurs that do not involve security, such as a named pipe with the same name already exists but with different configurations at the documentation of the CreateNamedPipe function



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    • Marked as answer by CodingAllDay Friday, May 20, 2011 8:14 PM
    Friday, May 20, 2011 4:48 PM

All replies

  • You are probably running the two processes under different user tokens (e.g. different user names, or same user name but different integrity levels). If so you need to modify the permission on the named pipe to allow desired user to have access to the pipe. 

    You can find sample that sets named pipe security in All-In-One IPC and RPC Code Samples.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Friday, May 20, 2011 12:31 AM
  • Thanks, however both application are invoked locally under the same user account.

    I read about the security descriptor and still have no clue how to solve it.

    A bit more info:

    (1) The C# server connects to C# client with default security descriptor (NULL).

    (2) The C++ client connects to another C++ server with default security descriptor (NULL).

    (3) The issue arises only when connecting pipes between C++ and C#.

     (4) The user account is an "Administrator" account (belongs to "Administrator" group).

    (5) Launching any (or both) with "Run as Administrator" option does not help.

    So how can it be related to security descriptor?

     

    Friday, May 20, 2011 8:18 AM
  • The default security descriptor should give the creator and administrators full control. If running both server and client as administrator, there should not be any security barrier between the two.

    There are some discussions of access denied error occurs that do not involve security, such as a named pipe with the same name already exists but with different configurations at the documentation of the CreateNamedPipe function



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    • Marked as answer by CodingAllDay Friday, May 20, 2011 8:14 PM
    Friday, May 20, 2011 4:48 PM
  • Thanks for the tip; you pointed me to the right direction.

    The problem had nothing to do with security, just with a small difference in pipe parameters between server and client.

    Now it works in all combinations.


    Friday, May 20, 2011 8:14 PM
  • What were those changes???? I'm having the same problem, but its a c++ server and a c# client
    Thursday, June 28, 2012 6:27 PM