How do I programmatically create a read-only network share?

How do I create an administrative network share [1] with read-only permissions from C / C ++ or Python on Windows XP?

[1] Required to access C: \ Program Files through a share.

+2


source to share


2 answers


First, create a share using NetShareAdd () . This will share the directory with the null

ACL, which is the same as allowing all users full access. Unable to configure permissions using NetShareAdd

in Windows.



Once the resource has been created, get the security descriptor for the share by calling GetNamedSecurityInfoW () , passing in the name of the share, SE_LMSHARE

how ObjectType

and DACL_SECURITY_INFORMATION

how SecurityInfo

. Once you have the handle, use normal Windows security calls to configure the ACL.

+4


source


Have a look at NetShareAdd () for C / C ++ (MSDN includes a sample program at the end of the page).



0


source







All Articles