How to create read-only network share programmatically?

前端 未结 2 1842
没有蜡笔的小新
没有蜡笔的小新 2021-01-15 04:23

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:\\Progra

2条回答
  •  清酒与你
    2021-01-15 05:18

    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.

提交回复
热议问题