System.IO.Pipes.PipeSecurity.RemoveAccessRule C# (CSharp) Method

RemoveAccessRule() public method

public RemoveAccessRule ( PipeAccessRule rule ) : bool
rule PipeAccessRule
return bool
        public bool RemoveAccessRule(PipeAccessRule rule)
        {
            if (rule == null)
            {
                throw new ArgumentNullException(nameof(rule));
            }

            // If the rule to be removed matches what is there currently then 
            // remove it unaltered. That is, don't mask off the Synchronize bit.
            AuthorizationRuleCollection rules = GetAccessRules(true, true, rule.IdentityReference.GetType());

            for (int i = 0; i < rules.Count; i++)
            {
                PipeAccessRule fsrule = rules[i] as PipeAccessRule;

                if ((fsrule != null) && (fsrule.PipeAccessRights == rule.PipeAccessRights)
                        && (fsrule.IdentityReference == rule.IdentityReference)
                        && (fsrule.AccessControlType == rule.AccessControlType))
                {
                    return base.RemoveAccessRule(rule);
                }
            }

            // It didn't exactly match any of the current rules so remove this way:
            // mask off the synchronize bit (that is automatically added for Allow)
            // before removing the ACL. The logic here should be same as Deny and hence
            // fake a call to AccessMaskFromRights as though the ACL is for Deny
            if (rule.PipeAccessRights != PipeAccessRights.FullControl)
            {
                return base.RemoveAccessRule(new PipeAccessRule(
                            rule.IdentityReference,
                            PipeAccessRule.AccessMaskFromRights(rule.PipeAccessRights, AccessControlType.Deny),
                            false,
                            rule.AccessControlType));
            }
            else
            {
                return base.RemoveAccessRule(rule);
            }
        }

Same methods

PipeSecurity::RemoveAccessRule ( System rule ) : bool