如何以编程方式创建只读网络共享? [英] How to create read-only network share programmatically?
问题描述
如何在 Windows XP 下通过 C/C++ 或 Python 创建具有只读权限的管理网络共享 [1]?
How does one create an administrative network share [1] with read-only permissions from C/C++ or Python under Windows XP?
[1] 为了通过共享访问 C:\Program Files.
[1] Necessary in order to access C:\Program Files over the share.
推荐答案
首先使用 NetShareAdd().这将使用 null
ACL 共享目录,这等效于允许每个人完全访问.无法在 Windows 上使用 NetShareAdd
配置权限.
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.
创建共享后,通过调用GetNamedSecurityInfoW() 传入共享名称,SE_LMSHARE
作为 ObjectType
,DACL_SECURITY_INFORMATION
作为安全信息
.获得描述符后,使用普通的 Windows 安全调用来配置 ACL.
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.
这篇关于如何以编程方式创建只读网络共享?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!