Пример #1
0
        public FileSystemSecurity GetSecurity(AccessControlSections sections)
        {
            lock (Lock) {
                DirectorySecurity security = new DirectorySecurity();

                if ((sections & AccessControlSections.Owner) != 0)
                {
                    security.SetOwner(_directory.Owner);
                }
                if ((sections & AccessControlSections.Group) != 0)
                {
                    security.SetGroup(_directory.Group);
                }
                if ((sections & AccessControlSections.Access) != 0)
                {
                    foreach (var r in _fileSystem.GetAccessRules(_directory))
                    {
                        security.AddAccessRule(
                            new FileSystemAccessRule(r.IdentityReference, r.FileSystemRights, r.InheritanceFlags, r.PropagationFlags, r.AccessControlType));
                    }
                }
                if ((sections & AccessControlSections.Audit) != 0)
                {
                    foreach (var r in _fileSystem.GetAuditRules(_directory))
                    {
                        security.AddAuditRule(
                            new FileSystemAuditRule(r.IdentityReference, r.FileSystemRights, r.InheritanceFlags, r.PropagationFlags, r.AuditFlags));
                    }
                }

                return(security);
            }
        }