GetAccessRules() public method

public GetAccessRules ( bool includeExplicit, bool includeInherited, System targetType ) : System.Security.AccessControl.AuthorizationRuleCollection
includeExplicit bool
includeInherited bool
targetType System
return System.Security.AccessControl.AuthorizationRuleCollection
Ejemplo n.º 1
0
        private FileSystemRights GetFileSystemRights(CommonObjectSecurity objectSecurity)
        {
            AuthorizationRuleCollection accessRules = objectSecurity.GetAccessRules(true, true, typeof (SecurityIdentifier));
            FileSystemRights fileSystemAllowRights = 0;
            FileSystemRights fileSystemDenyRights = 0;
            foreach (FileSystemAccessRule accessRule in accessRules)
            {
                IdentityReference identityReference = accessRule.IdentityReference;
                if (identityReference != _currentUserIdentifier && _currentUserGroups.All(reference => reference != identityReference))
                    continue;
                if (accessRule.AccessControlType == AccessControlType.Deny)
                {
                    fileSystemDenyRights = fileSystemDenyRights | accessRule.FileSystemRights;
                }
                else
                {
                    fileSystemAllowRights = fileSystemAllowRights | accessRule.FileSystemRights;
                }
            }

            return fileSystemAllowRights & (~fileSystemDenyRights);
        }