问题描述
我已经写了检查所有文件系统权限上的目录应用程序。
I've written an application that examines all of the file system permissions on a directory.
一个目录有很多的访问规则(类型 FileSystemAccessRule
)。
A directory has a number of access rules (of type FileSystemAccessRule
).
每个访问规则都有一个属性 FileSystemRights
,这是一个标志枚举。
Each access rule has a property FileSystemRights
, which is a flag enumeration.
在运行此,我把遇到的 FileSystemRights
值 268435456
(这涉及到 0x10000000处
十六进制)。
When running this, I keep encountering a FileSystemRights
value of 268435456
(which comes to 0x10000000
in hexadecimal).
此值只是不会出现在枚举!它实际上比最高的单标志值(同步
,其值的0x100000
)。
This value just doesn't appear in enumeration! It's actually higher than the highest single flag value (Synchronize
, having a value of 0x100000
).
有谁知道这是什么?
推荐答案
请参阅<一href="http://cjwdev.word$p$pss.com/2011/06/28/permissions-not-included-in-net-accessrule-filesystemrights-enum/">http://cjwdev.word$p$pss.com/2011/06/28/permissions-not-included-in-net-accessrule-filesystemrights-enum/
从该网页:
使用.NET你可能会认为确定哪些权限 分配到目录/文件应该是很容易的,因为有一个 FileSystemRights枚举定义似乎包含每一个可能的 允许一个文件/目录可以拥有和调用 AccessRule.FileSystemRights返回这些值的组合。 但是,你很快就会遇到一些权限,其中的价值 这个属性不匹配的任何值在FileSystemRights 枚举(我希望他们不要命名某些属性具有相同名称 作为一个类型,但嘿)。
这样做的最终结果是,对于某些文件/目录,你根本 不能确定哪个权限分配给它们。如果你这么做 AccessRule.FileSystemRights.ToString那么对于这些值,所有你看到 是一个数字,而不是描述(如修改,删除,FullControl 等等)。您可能会看到通用数字是:
The end result of this is that for some files/directories you simply cannot determine which permissions are assigned to them. If you do AccessRule.FileSystemRights.ToString then for these values all you see is a number rather than a description (e.g Modify, Delete, FullControl etc). Common numbers you might see are:
-1610612736,-536805376和268435456
-1610612736, –536805376, and 268435456
要制定出什么这些权限其实是,你需要看看 该位,当你把这个数字为32个独立的位被设置 而不是作为一个整数(如整数是32位),和比较 他们此图: http://msdn.microsoft.com/en-us/library/aa374896(v=vs.85).aspx
To work out what these permissions actually are, you need to look at which bits are set when you treat that number as 32 separate bits rather than as an Integer (as Integers are 32 bits long), and compare them to this diagram: http://msdn.microsoft.com/en-us/library/aa374896(v=vs.85).aspx
因此,例如,-1610612736具有第一比特和第三位设置, 这意味着它GENERIC_READ与GENERIC_EXECUTE组合。所以,现在 你可以将这些通用权限到特定文件 系统权限它们对应于
So for example, -1610612736 has the first bit and the third bit set, which means it is GENERIC_READ combined with GENERIC_EXECUTE. So now you can convert these generic permissions into the specific file system permissions that they correspond to.
您可以看到哪些权限每个通用许可映射到这里: http://msdn.microsoft.com/en-us/library/aa364399.aspx.要知道 这STANDARD_RIGHTS_READ,STANDARD_RIGHTS_EXECUTE和 STANDARD_RIGHTS_WRITE都是一样的东西(不知道为什么,似乎 怪我),其实都是等于 FileSystemRights.ReadPermissions值。
You can see which permissions each generic permission maps to here: http://msdn.microsoft.com/en-us/library/aa364399.aspx. Just be aware that STANDARD_RIGHTS_READ, STANDARD_RIGHTS_EXECUTE and STANDARD_RIGHTS_WRITE are all the same thing (no idea why, seems strange to me) and actually all equal the FileSystemRights.ReadPermissions value.
这篇关于遇到未在枚举定义的FileSystemRights值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!