您好,登錄后才能下訂單哦!
本篇文章給大家分享的是有關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_PRESENTEnd 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))
以上就是VBSCript中GenerateSDDL函數如何使用,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。