How does one create an administrative network share [1] with read-only permissions from C/C++ or Python under Windows XP?
[1] Necessary in order to access C:\Program Files over the share.
How does one create an administrative network share [1] with read-only permissions from C/C++ or Python under Windows XP?
[1] Necessary in order to access C:\Program Files over the share.
First create the share with NetShareAdd(). This will share the directory with a null
ACL, which is equavalent to allowing everyone full access. It is not possible to configure permissions with NetShareAdd
on Windows.
Once the share has been created, get the security descriptor for the share by calling GetNamedSecurityInfoW() passing in the share name, SE_LMSHARE
as the ObjectType
, and DACL_SECURITY_INFORMATION
as the SecurityInfo
. Once you have the descriptor, use the normal Windows security calls to configure the ACL.
Take a look at NetShareAdd() for C/C++ (the MSDN includes an example program at the end of the page).