新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
本篇文章给大家分享的是有关VBSCript中GenerateSDDL函数如何使用,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
创新互联于2013年创立,先为卫东等服务建站,卫东等地企业,进行企业商务咨询服务。为卫东企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。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函数如何使用,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注创新互联行业资讯频道。