通过迭代的权限在Windows文件系统在C#中的文件 [英] Iterate through permissions on a file in the windows file system in C#
问题描述
我发展在C#中的应用程序。我们的目标是获得在文件系统中一个给定的文件的权限。
I am developing an application in 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.
我不知道怎么去上面给定文件。任何想法?
I am not sure how to get the above for a given file. Any ideas ?
推荐答案
您想要创建一个<一个href="http://msdn.microsoft.com/en-us/library/system.security.permissions.fileiopermission%28v=vs.110%29.aspx"相对=nofollow> 的FileIOPermission
为每个文件对象,并挑选出的<一个href="http://msdn.microsoft.com/en-us/library/system.security.permissions.fileiopermission.allfiles%28v=vs.110%29.aspx"相对=nofollow> AllFiles
成员。它可以是 AllAccess
,追加
, noaccess下
的任意组合, PathDiscovery
,读
和
,但显然只写那几个逻辑意义。
You want to create a FileIOPermission
object for each file and pick out the AllFiles
member. It can be any combination of AllAccess
, Append
, NoAccess
, PathDiscovery
, Read
, and Write
, though obviously only a few of those make logical sense.
您可能也有兴趣在<一个href="http://msdn.microsoft.com/en-us/library/system.security.permissions.fileiopermission.getpathlist%28v=vs.110%29.aspx"相对=nofollow>的 GetPathList()
方法,效果显着。
You might also be interested in the GetPathList()
method, obviously.
有关休息,另外还有<一个href="http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement%28v=vs.110%29.aspx"相对=nofollow> System.DirectoryServices.AccountManagement
命名空间。这会是太大了,我钻进去,在这里,但是...啊,这个答案是一个非常好的开始。
For the rest, there's also the System.DirectoryServices.AccountManagement
namespace. That'd be too big for me to dig into, here, but...ah, this answer is a really good start.
这篇关于通过迭代的权限在Windows文件系统在C#中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!