复制代码 代码如下:
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
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- P1X3L《P1X3L》[320K/MP3][143MB]
- 群星.2022-良辰好景知几何电视剧原声带【SONY】【FLAC分轨】
- 庾澄庆.1991-管不住自己【福茂】【WAV+CUE】
- 欧倩怡.2001-Cindy(EP)【华星】【WAV+CUE】
- P1X3L《P1X3L》[FLAC/分轨][791.28MB]
- 茵达INDAHKUS《茵 the Blue》[320K/MP3][33.49MB]
- 茵达INDAHKUS《茵 the Blue》[FLAC/分轨][147.57MB]
- 老虎鱼AnneClarkwithUllavanDaelenJustinCiuche-Borderland-HiRes-Files24bit88.2kHz
- 江玲2004-百合盛开2CD[歌林][WAV+CUE]
- 孙露《怕什么孤单3CD》深圳音像[WAV分轨]
- s14全球总决赛目前是什么结果 s14全球总决赛赛程结果图一览
- s2TPA夺冠五人名单都有谁 tpa战队s2夺冠队员名单一览
- s13wbg战队成员都有谁 wbg战队s13成员名单一览
- 网友热议《幻兽帕鲁》停售、赔千万日元:那也赚麻了 不亏
- 这谁顶得住 《最终幻想7:重生》尤菲3D作品穿上终极芙蕾娜衣服