public virtual bool ModifyAuditRule(AccessControlModification modification, AuditRule rule, out bool modified) { if (rule == null) { throw new ArgumentNullException(nameof(rule)); } if (!this.AuditRuleType.GetTypeInfo().IsAssignableFrom(rule.GetType().GetTypeInfo())) { throw new ArgumentException( SR.AccessControl_InvalidAuditRuleType, nameof(rule)); } WriteLock(); try { return(ModifyAudit(modification, rule, out modified)); } finally { WriteUnlock(); } }
public virtual bool ModifyAuditRule(AccessControlModification modification, AuditRule rule, out bool modified) { if (rule == null) { throw new ArgumentNullException("rule"); } if (!this.AuditRuleType.IsAssignableFrom(rule.GetType())) { throw new ArgumentException( Environment.GetResourceString("AccessControl_InvalidAuditRuleType"), "rule"); } Contract.EndContractBlock(); WriteLock(); try { return(ModifyAudit(modification, rule, out modified)); } finally { WriteUnlock(); } }
/// <summary>将指定修改应用于与此 <see cref="T:System.Security.AccessControl.DirectoryObjectSecurity" /> 对象关联的系统访问控制列表 (SACL)。</summary> /// <returns>如果成功修改了 SACL,则为 true;否则为 false。</returns> /// <param name="modification">要应用于 SACL 的修改。</param> /// <param name="rule">要修改的审核规则。</param> /// <param name="modified">如果成功修改了 SACL,则为 true;否则为 false。</param> protected override bool ModifyAudit(AccessControlModification modification, AuditRule rule, out bool modified) { if (!this.AuditRuleType.IsAssignableFrom(rule.GetType())) { throw new ArgumentException(Environment.GetResourceString("AccessControl_InvalidAuditRuleType"), "rule"); } return(this.ModifyAudit(modification, rule as ObjectAuditRule, out modified)); }
protected override bool ModifyAudit(AccessControlModification modification, AuditRule rule, out bool modified) { //if (this.AccessRuleType.IsAssignableFrom(rule.GetType().GetTypeInfo())) ////if (!TypeExtensions.IsAssignableFrom(this.AuditRuleType, rule.GetType())) //{ // throw new ArgumentException( // SR.AccessControl_InvalidAuditRuleType, // "rule"); //} return(ModifyAudit(modification, rule as ObjectAuditRule, out modified)); }
public virtual bool ModifyAuditRule(AccessControlModification modification, AuditRule rule, out bool modified) { if (rule == null) { throw new ArgumentNullException("rule"); } if (!AuditRuleType.IsAssignableFrom(rule.GetType())) { throw new ArgumentException("rule"); } return(ModifyAudit(modification, rule, out modified)); }
protected void AddAuditRule(AuditRule rule) { if (rule == null) { throw new ArgumentNullException("rule"); } base.WriteLock(); try { bool flag; this.ModifyAudit(AccessControlModification.Add, rule, out flag); } finally { base.WriteUnlock(); } }
/// <summary>从与此 <see cref="T:System.Security.AccessControl.CommonObjectSecurity" /> 对象关联的系统访问控制列表 (SACL) 中移除与指定的审核规则完全匹配的所有审核规则。</summary> /// <param name="rule">要移除的审核规则。</param> protected void RemoveAuditRuleSpecific(AuditRule rule) { if (rule == null) { throw new ArgumentNullException("rule"); } this.WriteLock(); try { bool modified; this.ModifyAudit(AccessControlModification.RemoveSpecific, rule, out modified); } finally { this.WriteUnlock(); } }
protected void RemoveAuditRuleAll(AuditRule rule) { if (rule == null) { throw new ArgumentNullException(nameof(rule)); } WriteLock(); try { bool modified; ModifyAudit(AccessControlModification.RemoveAll, rule, out modified); } finally { WriteUnlock(); } }
protected bool RemoveAuditRule(AuditRule rule) { if (rule == null) { throw new ArgumentNullException("rule"); } Contract.EndContractBlock(); WriteLock(); try { bool modified; return(ModifyAudit(AccessControlModification.Remove, rule, out modified)); } finally { WriteUnlock(); } }
protected void SetAuditRule(AuditRule rule) { if (rule == null) { throw new ArgumentNullException("rule"); } Contract.EndContractBlock(); WriteLock(); try { bool modified; ModifyAudit(AccessControlModification.Set, rule, out modified); } finally { WriteUnlock(); } }
protected bool RemoveAuditRule(AuditRule rule) { bool flag2; if (rule == null) { throw new ArgumentNullException("rule"); } base.WriteLock(); try { bool flag; flag2 = this.ModifyAudit(AccessControlModification.Remove, rule, out flag); } finally { base.WriteUnlock(); } return(flag2); }
internal AuthorizationRuleCollection InternalGetAuditRules(bool includeExplicit, bool includeInherited, Type targetType) { List <AuthorizationRule> rules = new List <AuthorizationRule> (); ReadLock(); try { if (null != descriptor.SystemAcl) { foreach (GenericAce genericAce in descriptor.SystemAcl) { QualifiedAce ace = genericAce as QualifiedAce; if (null == ace) { continue; } if (ace.IsInherited && !includeInherited) { continue; } if (!ace.IsInherited && !includeExplicit) { continue; } if (AceQualifier.SystemAudit != ace.AceQualifier) { continue; } AuditRule rule = InternalAuditRuleFactory(ace, targetType); rules.Add(rule); } } } finally { ReadUnlock(); } return(new AuthorizationRuleCollection(rules.ToArray())); }
protected override bool ModifyAudit(AccessControlModification modification, AuditRule rule, out bool modified) { foreach (AuditRule r in audit_rules) { if (rule != r) { continue; } switch (modification) { case AccessControlModification.Add: AddAuditRule(rule); break; case AccessControlModification.Set: SetAuditRule(rule); break; //case AccessControlModification.Reset: // ResetAuditRule (rule); // break; case AccessControlModification.Remove: RemoveAuditRule(rule); break; case AccessControlModification.RemoveAll: RemoveAuditRuleAll(rule); break; case AccessControlModification.RemoveSpecific: RemoveAuditRuleSpecific(rule); break; } AuditRulesModified = true; modified = true; return(true); } modified = false; return(false); }
/// <summary>Applies the specified modification to the System Access Control List (SACL) associated with this <see cref="T:System.Security.AccessControl.CommonObjectSecurity" /> object.</summary> /// <returns>true if the SACL is successfully modified; otherwise, false.</returns> /// <param name="modification">The modification to apply to the SACL.</param> /// <param name="rule">The audit rule to modify.</param> /// <param name="modified">true if the SACL is successfully modified; otherwise, false.</param> protected override bool ModifyAudit(AccessControlModification modification, AuditRule rule, out bool modified) { foreach (AuditRule auditRule in this.audit_rules) { if (rule == auditRule) { switch (modification) { case AccessControlModification.Add: this.AddAuditRule(rule); break; case AccessControlModification.Set: this.SetAuditRule(rule); break; case AccessControlModification.Remove: this.RemoveAuditRule(rule); break; case AccessControlModification.RemoveAll: this.RemoveAuditRuleAll(rule); break; case AccessControlModification.RemoveSpecific: this.RemoveAuditRuleSpecific(rule); break; } base.AuditRulesModified = true; modified = true; return(true); } } modified = false; return(false); }
protected void SetAuditRule (AuditRule rule) { throw new NotImplementedException (); }
protected bool RemoveAuditRule (AuditRule rule) { throw new NotImplementedException (); }
protected override bool ModifyAudit(AccessControlModification modification, AuditRule rule, out bool modified) { if ( !this.AuditRuleType.IsAssignableFrom(rule.GetType()) ) { throw new ArgumentException( Environment.GetResourceString("AccessControl_InvalidAuditRuleType"), "rule"); } Contract.EndContractBlock(); return ModifyAudit(modification, rule as ObjectAuditRule, out modified); }
// // Modifies the SACL // protected override bool ModifyAudit( AccessControlModification modification, AuditRule rule, out bool modified ) { if (rule == null) { throw new ArgumentNullException("rule"); } Contract.EndContractBlock(); WriteLock(); try { bool result = true; if ( _securityDescriptor.SystemAcl == null ) { if ( modification == AccessControlModification.Remove || modification == AccessControlModification.RemoveAll || modification == AccessControlModification.RemoveSpecific ) { modified = false; return result; } _securityDescriptor.SystemAcl = new SystemAcl( IsContainer, IsDS, GenericAcl.AclRevision, 1 ); _securityDescriptor.AddControlFlags(ControlFlags.SystemAclPresent); } SecurityIdentifier sid = rule.IdentityReference.Translate( typeof( SecurityIdentifier )) as SecurityIdentifier; switch ( modification ) { case AccessControlModification.Add : _securityDescriptor.SystemAcl.AddAudit( rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags ); break; case AccessControlModification.Set : _securityDescriptor.SystemAcl.SetAudit( rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags ); break; case AccessControlModification.Reset : _securityDescriptor.SystemAcl.SetAudit( rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags ); break; case AccessControlModification.Remove : result = _securityDescriptor.SystemAcl.RemoveAudit( rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags ); break; case AccessControlModification.RemoveAll : result = _securityDescriptor.SystemAcl.RemoveAudit( AuditFlags.Failure | AuditFlags.Success, sid, -1, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, 0 ); if ( result == false ) { throw new InvalidProgramException(); } break; case AccessControlModification.RemoveSpecific : _securityDescriptor.SystemAcl.RemoveAuditSpecific(rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags ); break; default : throw new ArgumentOutOfRangeException( "modification", Environment.GetResourceString( "ArgumentOutOfRange_Enum" )); } modified = result; AuditRulesModified |= modified; return result; } finally { WriteUnlock(); } }
public virtual void RemoveAuditRuleSpecific(AuditRule <T> rule) { throw new NotImplementedException(); }
public virtual void RemoveAuditRuleSpecific(AuditRule <T> rule) { base.RemoveAuditRuleSpecific(rule); }
protected void AddAuditRule(AuditRule rule) { }
public override bool ModifyAuditRule(AccessControlModification modification, AuditRule rule, out bool modified) { if (!SaclRetrieved()) { throw new InvalidOperationException(Res.GetString(Res.CannotModifySacl)); } return base.ModifyAuditRule(modification, rule, out modified); }
protected override bool ModifyAudit (AccessControlModification modification, AuditRule rule, out bool modified) { if (null == rule) throw new ArgumentNullException ("rule"); modified = true; WriteLock (); try { switch (modification) { case AccessControlModification.Add: if (null == descriptor.SystemAcl) descriptor.SystemAcl = new SystemAcl (IsContainer, IsDS, 1); descriptor.SystemAcl.AddAudit (rule.AuditFlags, SidFromIR (rule.IdentityReference), rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; case AccessControlModification.Set: if (null == descriptor.SystemAcl) descriptor.SystemAcl = new SystemAcl (IsContainer, IsDS, 1); descriptor.SystemAcl.SetAudit (rule.AuditFlags, SidFromIR (rule.IdentityReference), rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; case AccessControlModification.Reset: break; case AccessControlModification.Remove: if (null == descriptor.SystemAcl) modified = false; else modified = descriptor.SystemAcl.RemoveAudit (rule.AuditFlags, SidFromIR (rule.IdentityReference), rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; case AccessControlModification.RemoveAll: PurgeAuditRules (rule.IdentityReference); break; case AccessControlModification.RemoveSpecific: if (null != descriptor.SystemAcl) descriptor.SystemAcl.RemoveAuditSpecific (rule.AuditFlags, SidFromIR (rule.IdentityReference), rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; default: throw new ArgumentOutOfRangeException ("modification"); } if (modified) AuditRulesModified = true; } finally { WriteUnlock (); } return modified; }
protected void SetAuditRule (AuditRule rule) { bool modified; ModifyAudit (AccessControlModification.Set, rule, out modified); }
/// <summary>Removes all audit rules that contain the same security identifier and qualifier as the specified audit rule in the System Access Control List (SACL) associated with this <see cref="T:System.Security.AccessControl.CommonObjectSecurity" /> object and then adds the specified audit rule.</summary><param name="rule">The audit rule to set.</param> protected void SetAuditRule(AuditRule rule) { throw new NotImplementedException(); }
protected void RemoveAuditRuleSpecific (AuditRule rule) { bool modified; ModifyAudit (AccessControlModification.RemoveSpecific, rule, out modified); }
public virtual new bool ModifyAuditRule(AccessControlModification modification, AuditRule rule, out bool modified) { Contract.Requires(this.AuditRuleType != null); modified = default(bool); return default(bool); }
public virtual bool ModifyAuditRule(AccessControlModification modification, AuditRule rule, ref bool modified) { throw new NotImplementedException(); }
protected override bool ModifyAudit(AccessControlModification modification, AuditRule rule, out bool modified) { modified = default(bool); return default(bool); }
public virtual bool RemoveAuditRule(AuditRule <T> rule) { throw new NotImplementedException(); }
protected bool RemoveAuditRule(AuditRule rule) { if (rule == null) { throw new ArgumentNullException(nameof(rule)); } Contract.EndContractBlock(); WriteLock(); try { bool modified; return ModifyAudit(AccessControlModification.Remove, rule, out modified); } finally { WriteUnlock(); } }
protected bool RemoveAuditRule(AuditRule rule) { bool flag2; if (rule == null) { throw new ArgumentNullException("rule"); } base.WriteLock(); try { bool flag; flag2 = this.ModifyAudit(AccessControlModification.Remove, rule, out flag); } finally { base.WriteUnlock(); } return flag2; }
protected override bool ModifyAudit (AccessControlModification modification, AuditRule rule, out bool modified) { modified = false; return modified; }
protected void RemoveAuditRuleSpecific( AuditRule rule ) { if ( rule == null ) { throw new ArgumentNullException( "rule" ); } Contract.EndContractBlock(); WriteLock(); try { bool modified; ModifyAudit( AccessControlModification.RemoveSpecific, rule, out modified ); } finally { WriteUnlock(); } }
/// <summary>Removes all audit rules that exactly match the specified audit rule from the System Access Control List (SACL) associated with this <see cref="T:System.Security.AccessControl.CommonObjectSecurity" /> object.</summary><param name="rule">The audit rule to remove.</param> protected void RemoveAuditRuleSpecific(AuditRule rule) { throw new NotImplementedException(); }
// Audit protected void AddAuditRule (AuditRule rule) { audit_rules.Add (rule); AuditRulesModified = true; }
// // Modifies the SACL // protected override bool ModifyAudit(AccessControlModification modification, AuditRule rule, out bool modified) { if (rule == null) { throw new ArgumentNullException("rule"); } Contract.EndContractBlock(); WriteLock(); try { bool result = true; if (_securityDescriptor.SystemAcl == null) { if (modification == AccessControlModification.Remove || modification == AccessControlModification.RemoveAll || modification == AccessControlModification.RemoveSpecific) { modified = false; return(result); } _securityDescriptor.SystemAcl = new SystemAcl(IsContainer, IsDS, GenericAcl.AclRevision, 1); _securityDescriptor.AddControlFlags(ControlFlags.SystemAclPresent); } SecurityIdentifier sid = rule.IdentityReference.Translate(typeof(SecurityIdentifier)) as SecurityIdentifier; switch (modification) { case AccessControlModification.Add: _securityDescriptor.SystemAcl.AddAudit(rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; case AccessControlModification.Set: _securityDescriptor.SystemAcl.SetAudit(rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; case AccessControlModification.Reset: _securityDescriptor.SystemAcl.SetAudit(rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; case AccessControlModification.Remove: result = _securityDescriptor.SystemAcl.RemoveAudit(rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; case AccessControlModification.RemoveAll: result = _securityDescriptor.SystemAcl.RemoveAudit(AuditFlags.Failure | AuditFlags.Success, sid, -1, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, 0); if (result == false) { throw new InvalidOperationException(); } break; case AccessControlModification.RemoveSpecific: _securityDescriptor.SystemAcl.RemoveAuditSpecific(rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; default: throw new ArgumentOutOfRangeException( "modification", SR.ArgumentOutOfRange_Enum); } modified = result; AuditRulesModified |= modified; return(result); } finally { WriteUnlock(); } }
protected void RemoveAuditRuleSpecific (AuditRule rule) { throw new NotImplementedException (); }
protected override bool ModifyAudit(AccessControlModification modification, AuditRule rule, out bool modified) { bool flag2; if (rule == null) { throw new ArgumentNullException("rule"); } base.WriteLock(); try { bool flag = true; if (base._securityDescriptor.SystemAcl == null) { if (((modification == AccessControlModification.Remove) || (modification == AccessControlModification.RemoveAll)) || (modification == AccessControlModification.RemoveSpecific)) { modified = false; return flag; } base._securityDescriptor.SystemAcl = new SystemAcl(base.IsContainer, base.IsDS, GenericAcl.AclRevision, 1); base._securityDescriptor.AddControlFlags(ControlFlags.SystemAclPresent); } SecurityIdentifier sid = rule.IdentityReference.Translate(typeof(SecurityIdentifier)) as SecurityIdentifier; switch (modification) { case AccessControlModification.Add: base._securityDescriptor.SystemAcl.AddAudit(rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; case AccessControlModification.Set: base._securityDescriptor.SystemAcl.SetAudit(rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; case AccessControlModification.Reset: base._securityDescriptor.SystemAcl.SetAudit(rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; case AccessControlModification.Remove: flag = base._securityDescriptor.SystemAcl.RemoveAudit(rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; case AccessControlModification.RemoveAll: flag = base._securityDescriptor.SystemAcl.RemoveAudit(AuditFlags.Failure | AuditFlags.Success, sid, -1, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None); if (!flag) { throw new InvalidProgramException(); } break; case AccessControlModification.RemoveSpecific: base._securityDescriptor.SystemAcl.RemoveAuditSpecific(rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags); break; default: throw new ArgumentOutOfRangeException("modification", Environment.GetResourceString("ArgumentOutOfRange_Enum")); } modified = flag; base.AuditRulesModified |= modified; flag2 = flag; } finally { base.WriteUnlock(); } return flag2; }
protected override bool ModifyAudit (AccessControlModification modification, AuditRule rule, out bool modified) { foreach (AuditRule r in audit_rules) { if (rule != r) continue; switch (modification) { case AccessControlModification.Add: AddAuditRule (rule); break; case AccessControlModification.Set: SetAuditRule (rule); break; //case AccessControlModification.Reset: // ResetAuditRule (rule); // break; case AccessControlModification.Remove: RemoveAuditRule (rule); break; case AccessControlModification.RemoveAll: RemoveAuditRuleAll (rule); break; case AccessControlModification.RemoveSpecific: RemoveAuditRuleSpecific (rule); break; } AuditRulesModified = true; modified = true; return true; } modified = false; return false; }
public virtual bool RemoveAuditRule(AuditRule <T> rule) { return(base.RemoveAuditRule(rule)); }
/// <summary>Removes audit rules that contain the same security identifier and access mask as the specified audit rule from the System Access Control List (SACL) associated with this <see cref="T:System.Security.AccessControl.CommonObjectSecurity" /> object.</summary><returns>true if the audit rule was successfully removed; otherwise, false.</returns><param name="rule">The audit rule to remove.</param> protected bool RemoveAuditRule(AuditRule rule) { throw new NotImplementedException(); }
protected bool RemoveAuditRule (AuditRule rule) { bool modified; return ModifyAudit (AccessControlModification.Remove, rule, out modified); }
public virtual bool ModifyAuditRule(AccessControlModification modification, AuditRule rule, out bool modified) { if ( rule == null ) { throw new ArgumentNullException( "rule" ); } if ( !this.AuditRuleType.IsAssignableFrom(rule.GetType()) ) { throw new ArgumentException( Environment.GetResourceString("AccessControl_InvalidAuditRuleType"), "rule"); } Contract.EndContractBlock(); WriteLock(); try { return ModifyAudit(modification, rule, out modified); } finally { WriteUnlock(); } }
protected abstract bool ModifyAudit( AccessControlModification modification, AuditRule rule, out bool modified );
public virtual void AddAuditRule(AuditRule <T> rule) { base.AddAuditRule(rule); }
protected bool RemoveAuditRule(AuditRule rule) { return default(bool); }
protected override bool ModifyAudit(AccessControlModification modification, AuditRule rule, out bool modified) { //if (this.AccessRuleType.IsAssignableFrom(rule.GetType().GetTypeInfo())) ////if (!TypeExtensions.IsAssignableFrom(this.AuditRuleType, rule.GetType())) //{ // throw new ArgumentException( // SR.AccessControl_InvalidAuditRuleType, // "rule"); //} Contract.EndContractBlock(); return ModifyAudit(modification, rule as ObjectAuditRule, out modified); }
public virtual bool ModifyAuditRule (AccessControlModification modification, AuditRule rule, out bool modified) { throw new NotImplementedException (); }
public virtual bool ModifyAuditRule(AccessControlModification modification, AuditRule rule, out bool modified) { if ( rule == null ) { throw new ArgumentNullException( nameof(rule)); } if ( !this.AuditRuleType.GetTypeInfo().IsAssignableFrom(rule.GetType().GetTypeInfo()) ) { throw new ArgumentException( SR.AccessControl_InvalidAuditRuleType, nameof(rule)); } Contract.EndContractBlock(); WriteLock(); try { return ModifyAudit(modification, rule, out modified); } finally { WriteUnlock(); } }
protected override bool ModifyAudit(AccessControlModification modification, AuditRule rule, out bool modified) { throw new NotImplementedException(); }
public virtual void SetAuditRule(AuditRule <T> rule) { base.SetAuditRule(rule); }
public override bool ModifyAuditRule(AccessControlModification modification, AuditRule rule, out bool modified) { if (this.SaclRetrieved()) { return base.ModifyAuditRule(modification, rule, out modified); } else { throw new InvalidOperationException("CannotModifySacl"); } }
public virtual void RemoveAuditRuleAll(AuditRule <T> rule) { base.RemoveAuditRuleAll(rule); }
public virtual bool ModifyAuditRule (AccessControlModification modification, AuditRule rule, out bool modified) { if (rule == null) throw new ArgumentNullException ("rule"); if (!AuditRuleType.IsAssignableFrom (rule.GetType())) throw new ArgumentException ("rule"); return ModifyAudit (modification, rule, out modified); }
protected abstract bool ModifyAudit(AccessControlModification modification, AuditRule rule, ref bool modified);
public virtual void SetAuditRule(AuditRule <T> rule) { SetAuditRule((AuditRule)rule); }
public virtual void SetAuditRule(AuditRule <T> rule) { throw new NotImplementedException(); }