VBSCript之GenerateSDDL函数(权限设置)
function generatesddl(accountname, accessflag, accesstype, accessmask)
dim accounts, objwmi, objsid, objtru, objace
const set_dacl_present = &h8004
set objwmi = getobject("winmgmts:" & "{impersonationlevel=impersonate, (security)}!\\.\root\cimv2")
set accounts = objwmi.execquery("select * from win32_account where name='" & accountname & "'")
for each account in accounts
strsid = account.sid
next
set objsid = objwmi.get("win32_sid.sid='"& strsid &"'")
set objtru = objwmi.get("win32_trustee").spawninstance_()
objtru.domain = objsid.referenceddomainname
objtru.name = objsid.accountname
objtru.sid = objsid.binaryrepresentation
objtru.sidlength = objsid.sidlength
objtru.sidstring = objsid.sid
set objace = objwmi.get("win32_ace").spawninstance_()
objace.trustee = objtru
objace.acetype = accesstype
objace.accessmask = accessmask
objace.aceflags = accessflag
set generatesddl = objwmi.get("win32_securitydescriptor").spawninstance_()
generatesddl.owner = objtru
generatesddl.dacl = array(objace)
generatesddl.controlflags = set_dacl_present
end function
例子:
strpath = "d:\\1.txt"
set objwmi = getobject("winmgmts:" & "{impersonationlevel=impersonate, (security)}!\\.\root\cimv2")
set objsec = objwmi.get("win32_logicalfilesecuritysetting.path='" & strpath & "'")
objsec.setsecuritydescriptor(generatesddl("everyone", &h0, &h1, &h100e0))
文章来源: http://www.enun.net/?p=1255
上一篇: JS 百度地图-右键菜单
下一篇: jQuery---CSS操作
推荐阅读
-
Linux mkdir函数mode权限设置方法
-
LINUX安全运维之:文件系统的权限修改与安全设置
-
jquery中ajax函数执行顺序问题之如何设置同步
-
Linux mkdir函数mode权限设置方法
-
PHP图像处理之使用imagecolorallocate()函数设置颜色例子
-
windows 服务器安全之磁盘访问权限设置[完整篇]
-
php的mkdir()函数创建文件夹比较安全的权限设置方法
-
matplotlib常见函数之plt.rcParams、matshow的使用(坐标轴设置)
-
Win2008 R2 WEB 服务器安全设置指南之文件夹权限设置技巧
-
VBSCript之GenerateSDDL函数(权限设置)