asp调用WMI设置磁盘文件夹用户访问权限的问题!
neeao 2005-07-13 05:11:39 msdn中的一个例子,用这个方法可以设置用户访问权限,但是遇到了一个问题,就是没法设置权限继承!哪位大哥有好的方法不妨说下!
' Connect to WMI and get the file security object for the testfolder directory
Set wmiFileSecSetting = GetObject ("winmgmts:Win32_LogicalFileSecuritySetting.path='c:\\testfolder'")
' Use the Win32_LogicalFileSecuritySetting Caption property to create a simple header before
' dumping the discretionary access control list (DACL).
Wscript.Echo wmiFileSecSetting.Caption & ":" & vbCrLf
' Obtain existing security descriptor for folder
RetVal = wmiFileSecSetting.GetSecurityDescriptor(wmiSecurityDescriptor)
If Err <> 0 Then
WScript.Echo "GetSecurityDescriptor failed" & VBCRLF & Err.Number & VBCRLF & Err.Description
WScript.Quit
Else
WScript.Echo "GetSecurityDescriptor suceeded"
End If
' Retrieve the content of Win32_SecurityDescriptor DACL property.
' The DACL is an array of Win32_ACE objects.
DACL = wmiSecurityDescriptor.DACL
' Display the control flags in the descriptor.
Wscript.Echo "Control Flags: " & wmiSecurityDescriptor.ControlFlags
' Obtain the trustee for each access control entry (ACE) and change the permissions
' in the AccessMask for each ACE to read, write, and delete.
For each wmiAce in DACL
' Get Win32_Trustee object from ACE
Set Trustee = wmiAce.Trustee
' wscript.echo "Trustee Domain: " & Trustee.Domain
wscript.echo "Trustee Name: " & Trustee.Name
wscript.echo "Access Mask: " & wmiAce.AccessMask
' Set read access to the owner, group, and DACL of the security descriptor (131072)
wmiAce.AccessMask = 131072
wscript.echo "Access Mask: " & wmiAce.AccessMask
Next
' Call the Win32_LogicalFileSecuritySetting.SetSecurityDescriptor method
' to write the new security descriptor.
RetVal = wmiFileSecSetting.SetSecurityDescriptor(wmiSecurityDescriptor)
Wscript.Echo "ReturnValue is: " & RetVal