sol17-2.vbs

来自「Apress - Managing Enterprise Systems Wit」· VBS 代码 · 共 25 行

VBS
25
字号
'grant the user Freds Read/Execute permissions on the report.doc file
Const RIGHT_GENERIC_READ = 1179785
Const RIGHT_GENERIC_EXECUTE = 1179808
Const ACETYPE_ACCESS_ALLOWED = 0 
Dim objDACL, objNewAce, objACE
Dim objSecurity, objSD
Set objSecurity = CreateObject("ADsSecurity") 'create security object
Set objSD = objSecurity.GetSecurityDescriptor("FILE://d:\data\report.doc")
Set objDACL = objSD.DiscretionaryAcl 'get the Discretionary ACL DACL
Set objNewAce = CreateObject("AccessControlEntry")

'Set the properties for the ACE. Set the trustee to be the Freds account,
objNewAce.Trustee = "Acme\FSmith"
'allow permissions to read and execute file
objNewAce.AccessMask = RIGHT_GENERIC_READ Or RIGHT_GENERIC_EXECUTE
'allow access to file
objNewAce.AceType = ACETYPE_ACCESS_ALLOWED

'add ACE to DACL
objDACL.AddAce objNewAce
'assign the DACL back to the security descriptor
objSD.DiscretionaryAcl = objDACL
'set the security descriptor for the file
objSecurity.SetSecurityDescriptor objSD

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?