如何检查用户是否对共享文件夹具有完全控制权限?
我使用以下代码来检查 DACL 中是否存在某个用户:
Dim l_managemantObject As ManagementBaseObject() = CType(securityDescriptor.Properties("DACL").Value, ManagementBaseObject())
For Each mObject As ManagementBaseObject In l_managemantObject
l_name = CType(mObject.GetPropertyValue("Trustee"), ManagementBaseObject).Properties("Name").Value.ToString
If CType(mObject.GetPropertyValue("Trustee"), ManagementBaseObject).Properties("Domain").Value IsNot Nothing Then
l_domain = CType(mObject.GetPropertyValue("Trustee"), ManagementBaseObject).Properties("Domain").Value.ToString()
End If
If users.UserName.ToLower = (l_domain & "\" & l_name).ToLower Then
Return True
End If
Next
如您所见,我能够获取用户名和域。但如何检查用户是否拥有 FullControl
权限?
编辑:
我做了进一步的调查,发现使用GetAccessMask
,我可以检索对代表其返回实例的用户或组所持有的共享的访问权限。
所以剩下要找出的是: 如何获取特定用户AccessMask
?
I use the following code in order to check if certin user exists in the DACL
:
Dim l_managemantObject As ManagementBaseObject() = CType(securityDescriptor.Properties("DACL").Value, ManagementBaseObject())
For Each mObject As ManagementBaseObject In l_managemantObject
l_name = CType(mObject.GetPropertyValue("Trustee"), ManagementBaseObject).Properties("Name").Value.ToString
If CType(mObject.GetPropertyValue("Trustee"), ManagementBaseObject).Properties("Domain").Value IsNot Nothing Then
l_domain = CType(mObject.GetPropertyValue("Trustee"), ManagementBaseObject).Properties("Domain").Value.ToString()
End If
If users.UserName.ToLower = (l_domain & "\" & l_name).ToLower Then
Return True
End If
Next
As you can see, I'm able to get the username and domain. But how do I check if the user has FullControl
permissions?
Edit:
I've done furthur investigation and found that using GetAccessMask
, I can retrieve the access rights to the share held by the user or group on whose behalf the instance is returned.
So whats left to find out is:
How to get a specific user AccessMask
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它一直在我眼皮子底下,在 managementObject 上使用
GetPropertyValue("AccessMask")
获取权限级别。完整方法:
It was under my nose all the time, using
GetPropertyValue("AccessMask")
on the managementObject gets the permission level.Full method: