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
...全文
436 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
尚和空四 2005-12-09
  • 打赏
  • 举报
回复
<script language='vbscript'>
Dim arrNames()
intSize = 0

Set objGroup = GetObject("LDAP://CN=Accountants,OU=Finance,DC=fabrikam,DC=com")

For Each strUser in objGroup.Member
Set objUser = GetObject("LDAP://" & strUser)
ReDim Preserve arrNames(intSize)
arrNames(intSize) = objUser.CN
intSize = intSize + 1
Next

For i = (UBound(arrNames) - 1) to 0 Step -1
For j= 0 to i
If UCase(arrNames(j)) > UCase(arrNames(j+1)) Then
strHolder = arrNames(j+1)
arrNames(j+1) = arrNames(j)
arrNames(j) = strHolder
End If
Next
Next

For Each strName in arrNames
alert(strName)
Next

</script>
尚和空四 2005-09-26
  • 打赏
  • 举报
回复
看你什么系统了 在2k下通用
对以前的 不好用的
白夜花寒 2005-07-13
  • 打赏
  • 举报
回复
wmi的运用有操作系统的问题,不是所有的例子都能用的
neeao 2005-07-13
  • 打赏
  • 举报
回复
没人知道了么!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11

28,392

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧