Beispiel #1
0
 public AccessRule(DirectoryPermissions dir, FileSystemAccessRule ace)
 {
     Dir         = dir;
     Account     = Entity.GetEntity(ace.IdentityReference.Value);
     Type        = ace.AccessControlType;
     Rights      = ace.FileSystemRights;
     IsInherited = ace.IsInherited;
 }
Beispiel #2
0
 public AccessRule(DirectoryPermissions dir, Entity account, AccessControlType type, FileSystemRights rights, bool isInherited)
 {
     Dir         = dir;
     Account     = account;
     Type        = type;
     Rights      = rights;
     IsInherited = isInherited;
 }
        public static List <AccessRule> GetAccessRules(DirectoryPermissions dir, bool recursive = true)
        {
            List <AccessRule> accessRules = new List <AccessRule>();
            var acCollection = new DirectoryInfo(dir.DirPath).GetAccessControl().GetAccessRules(
                true, true, typeof(System.Security.Principal.NTAccount));

            foreach (FileSystemAccessRule ace in acCollection)
            {
                var rule = new AccessRule(dir, ace);
                if (!rule.IsExpandable)
                {
                    AddRule(accessRules, rule);
                    continue;
                }
                foreach (var subRule in rule.Expand())
                {
                    AddRule(accessRules, subRule);
                }
            }
            return(accessRules);
        }