![](/img/trans.png)
[英]How to check if “Everyone” has full control permissions to a file in c#
[英]How can I verify in C# if a folder has “Security” to “Everyone - Full Control: Allow”?
它应该像
var ctrl = new DirectoryInfo(@"D:\something").GetAccessControl();
var everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
var accessRules = ctrl.GetAccessRules(true, true, typeof(SecurityIdentifier));
var result = accessRules
.Cast<FileSystemAccessRule>()
.Any(rule =>
rule.IdentityReference.Value == everyone.Value && // check everyone
rule.AccessControlType == AccessControlType.Allow && // check allow
rule.FileSystemRights == FileSystemRights.FullControl); // check full control
注意:这只是 windows(显然),您可能需要System.IO.FileSystem.AccessControl
nuget
其他资源
返回目录的 Windows 访问控制列表 (ACL)。
表示安全标识符 (SID) 并为 SID 提供封送和比较操作。
表示匹配所有人的 SID。
DirectoryObjectSecurity.GetAccessRules(Boolean, Boolean, Type) 方法
获取与指定安全标识符关联的访问规则的集合。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.