I need to programmatically create a directory that grants "Full Control" to the group "Everyone". If I use
CreateDirectory(path, NULL);
This will, according to the Win32 SDK documentation, create a directory that inherits from its parent directory. I do not want to inherit the access rights of the parent directory I need to ensure that "Everyone" has full control over the directory.
Obviously, this will require setting up the SECURITY_ATTRIBUTES
structure with the appropriate security descriptor. How do I do that?
Here's one technique that seems to work:
Note that this sample code has absolutely no error checking -- you'll have to supply that yourself.
See if you can use SetSecurityInfo()
In the description of the optional pDacl argument:
I prefer the following code snippet as it creates a folder inheriting default rights - which seems the right thing to do - other software / the user might have setup specific inheritable rights on a directory for a legitimate reason - then adds a Full Control explicit access entry for the built in "Users" group.