Vista security and named pipes
-
I have an application which uses named pipes to communicate and works as expected in XP but in Vista the CreateNamedPipe() function fails with ERROR_ACCESS_DENIED. I am attempting to use ConvertStringSecurityDescriptortoSecurityDescriptor() to create a SECURITY_DESCRIPTOR but this returns ERROR_INVALID_PARAMETER, the code I'm using is:
//// Imports and structures [DllImport("advapi32", SetLastError=true)] internal static extern bool ConvertStringSecurityDescriptorToSecurityDescriptor(string StringSecurityDescriptor, uint StringSDRevision, ref IntPtr securityDescriptor, ref int SecurityDescriptorSize); [StructLayout(LayoutKind.Sequential)] class SECURITY_ATTRIBUTES { public int nLength; public IntPtr lpSecurityDescriptor; public bool bInheritHandle; } //// End of imports //// Code SECURITY_ATTRIBUTES structure = new SECURITY_ATTRIBUTES(); string strsecdesc = "D: (A;;GRGW;;;S-1-1-0)"; <- This should give generic read/write to Everyone group int securityDescriptorSize = 0; ConvertStringSecurityDescriptorToSecurityDescriptor(strsecdesc, 1, ref structure.lpSecurityDescriptor, ref securityDescriptorSize); <- GetLastError() here returns ERROR_INVALID_PARAMETER
Can anyone see anything obviously wrong with this code for Vista? Thanks.Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!
-
I have an application which uses named pipes to communicate and works as expected in XP but in Vista the CreateNamedPipe() function fails with ERROR_ACCESS_DENIED. I am attempting to use ConvertStringSecurityDescriptortoSecurityDescriptor() to create a SECURITY_DESCRIPTOR but this returns ERROR_INVALID_PARAMETER, the code I'm using is:
//// Imports and structures [DllImport("advapi32", SetLastError=true)] internal static extern bool ConvertStringSecurityDescriptorToSecurityDescriptor(string StringSecurityDescriptor, uint StringSDRevision, ref IntPtr securityDescriptor, ref int SecurityDescriptorSize); [StructLayout(LayoutKind.Sequential)] class SECURITY_ATTRIBUTES { public int nLength; public IntPtr lpSecurityDescriptor; public bool bInheritHandle; } //// End of imports //// Code SECURITY_ATTRIBUTES structure = new SECURITY_ATTRIBUTES(); string strsecdesc = "D: (A;;GRGW;;;S-1-1-0)"; <- This should give generic read/write to Everyone group int securityDescriptorSize = 0; ConvertStringSecurityDescriptorToSecurityDescriptor(strsecdesc, 1, ref structure.lpSecurityDescriptor, ref securityDescriptorSize); <- GetLastError() here returns ERROR_INVALID_PARAMETER
Can anyone see anything obviously wrong with this code for Vista? Thanks.Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!
You have a space in your security descriptor text string. That's not allowed according to the MSDN documentation. Vista is most likely stricter at interpreting the string. As a style point I would prefer using the alias "WD" for 'Everyone', rather than the SID S-1-1-0.
DoEvents: Generating unexpected recursion since 1991