jef*_*ost 1 .net vb.net file active-directory
我正在编写代码来解析文件目录列表并确定哪些 AD 组具有访问权限。该信息在文件属性安全选项卡下的操作系统中可用,但我无法在 vb.net(或 c#)中找到任何检索该信息的代码示例。任何人都有代码可以做到这一点?
从文档(应用程序开发基金会):
以下代码示例(需要 System.Security.AccessControl 和 System.Security.Principal 命名空间)演示了如何显示文件夹的访问规则 (DACL);但是,可以使用相同的技术来分析文件、注册表值或其他对象:
' You could also call Directory.GetAccessControl for the following line
Dim ds As DirectorySecurity = New DirectorySecurity("C:\Program Files", AccessControlSections.Access)
Dim arc As AuthorizationRuleCollection = ds.GetAccessRules(True, _
True, GetType(NTAccount))
For Each ar As FileSystemAccessRule In arc
Console.WriteLine(ar.IdentityReference.ToString + ": " + _
ar.AccessControlType.ToString + " " + ar.FileSystemRights.ToString)
Next
Run Code Online (Sandbox Code Playgroud)