简体   繁体   English

通过C#在Windows文件系统中的文件上的权限进行迭代

[英]Iterate through permissions on a file in the windows file system in C#

I am developing an application in C#. 我正在用C#开发应用程序。 The goal is to get the permissions on a given file in the file system. 目的是获得文件系统中给定文件的权限。

This would include inherited permissions and permissions directly assigned to the file. 这将包括继承的权限和直接分配给文件的权限。

I want to get AD groups , local groups and domain users and local users who have been assigned Read, Write, Read & Execute, List Folder Contents, Modify and Full Control on a given file. 我想获取AD groupslocal groupsdomain users以及已分配给定文件的Read, Write, Read & Execute, List Folder Contents, Modify and Full Control domain users local users

I am not sure how to get the above for a given file. 我不确定如何获取给定文件的以上内容。 Any ideas ? 有任何想法吗 ?

You want to create a FileIOPermission object for each file and pick out the AllFiles member. 您要为每个文件创建一个FileIOPermission对象,并挑选AllFiles成员。 It can be any combination of AllAccess , Append , NoAccess , PathDiscovery , Read , and Write , though obviously only a few of those make logical sense. 它可以是AllAccessAppendNoAccessPathDiscoveryReadWrite任意组合,尽管显然只有少数几个具有逻辑意义。

You might also be interested in the GetPathList() method , obviously. 显然,您可能也对GetPathList()方法感兴趣。

For the rest, there's also the System.DirectoryServices.AccountManagement namespace . 其余的还有System.DirectoryServices.AccountManagement命名空间 That'd be too big for me to dig into, here, but...ah, this answer is a really good start. 这对于我来说太大了,但是...嗯, 这个答案是一个很好的开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM