Code from this question P/Invokes ConvertStringSecurityDescriptorToSecurityDescriptorW()
WinAPI function to convert the following "magic string"
S:(ML;;NW;;;LW)
into a security descriptor object which is then used to set access control on a named pipe. The "magic string" is actually a so-called system access control list, also mentioned as SACL or system ACL in MSDN.
I'm trying to make use of .NET class System.IO.Pipes.PipeSecurity
to achieve the same effect without P/Invoke. Looks like I need to create a SecurityIdentifier
object but when I pass the string representation of ACL shown above into SecurityIdentifier
constructor I get ArgumentException
so it looks like it's not a proper SDDL string.
I tried to use RawSecurityDescriptor
which I could later convert into SDDL form and pass the conversion result into SecurityIdentifier
constructor. If I construct RawSecurityDescriptor
from the string above I get a descriptor with empty SACL (SystemAcl getter returns S:
). However RawSecurityDescriptor
has a setter for SystemAcl
too so maybe I could craft that myself and assign it to SystemAcl
field.
I've looked into quite a lot of examples and I still cannot figure out how I would convert the string shown above into a SystemAcl
. Is there any description of how those all-caps parts should be interpreted and converted into SystemAcl
?