![](/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.