private void ValidateRuleEsnCompatibility(HygieneFilterRule rule) { if (rule is HostedContentFilterRule && ((HostedContentFilterPolicy)this.effectivePolicyObject).EnableEndUserSpamNotifications && !((HostedContentFilterRule)rule).IsEsnCompatible) { base.WriteError(new OperationNotAllowedException(Strings.ErrorCannotScopeEsnPolicy(this.effectivePolicyObject.Name)), ErrorCategory.InvalidOperation, null); } }
private void SetRuleWithoutPriorityChange(ADRuleStorageManager storedRules) { TransportRule transportRule = (TransportRule)TransportRuleParser.Instance.GetRule(this.DataObject.Xml); HygieneFilterRule hygieneFilterRule = this.CreateTaskRuleFromInternalRule(transportRule, -1); this.UpdateRuleFromParameters(hygieneFilterRule); this.ValidateRuleEsnCompatibility(hygieneFilterRule); transportRule = hygieneFilterRule.ToInternalRule(); this.DataObject.Xml = TransportRuleSerializer.Instance.SaveRuleToString(transportRule); if (base.Fields.IsModified("Name") && !storedRules.CanRename((ADObjectId)this.DataObject.Identity, ((ADObjectId)this.DataObject.Identity).Name, transportRule.Name)) { base.WriteError(new ArgumentException(Strings.RuleNameAlreadyExist, "Name"), ErrorCategory.InvalidArgument, this.Name); } base.InternalProcessRecord(); }
private static RuleDescription BuildRuleDescription(HygieneFilterRule rule) { RuleDescription ruleDescription = new RuleDescription(); if (rule.Conditions != null && rule.Conditions.Length > 0) { foreach (TransportRulePredicate transportRulePredicate in rule.Conditions) { ruleDescription.ConditionDescriptions.Add(transportRulePredicate.Description); } } ruleDescription.ActionDescriptions.Add(rule.BuildActionDescription()); if (rule.Exceptions != null && rule.Exceptions.Length > 0) { foreach (TransportRulePredicate transportRulePredicate2 in rule.Exceptions) { ruleDescription.ExceptionDescriptions.Add(transportRulePredicate2.Description); } } return(ruleDescription); }
private void SetRuleWithPriorityChange(ADRuleStorageManager storedRules) { TransportRule transportRule; int priority; storedRules.GetRule(this.DataObject.Identity, out transportRule, out priority); if (transportRule == null) { base.WriteError(new ArgumentException(Strings.RuleNotFound(this.Identity.ToString()), "Identity"), ErrorCategory.InvalidArgument, this.Identity); } HygieneFilterRule hygieneFilterRule = this.CreateTaskRuleFromInternalRule(transportRule, priority); this.UpdateRuleFromParameters(hygieneFilterRule); this.ValidateRuleEsnCompatibility(hygieneFilterRule); transportRule = hygieneFilterRule.ToInternalRule(); try { storedRules.UpdateRule(transportRule, hygieneFilterRule.Identity, hygieneFilterRule.Priority); } catch (RulesValidationException) { base.WriteError(new ArgumentException(Strings.RuleNameAlreadyExist, "Name"), ErrorCategory.InvalidArgument, this.Name); } }
private void UpdateRuleFromParameters(HygieneFilterRule rule) { if (this.Name != null) { rule.Name = this.Name; } if (this.Comments != null) { rule.Comments = this.Comments; } if (base.Fields.IsModified("Priority")) { rule.Priority = this.Priority; } if (this.Conditions != null) { rule.Conditions = this.Conditions; } else { List <TransportRulePredicate> list = new List <TransportRulePredicate>(); if (rule.Conditions != null) { foreach (TransportRulePredicate transportRulePredicate in rule.Conditions) { if (!this.conditionTypesToUpdate.Contains(transportRulePredicate.GetType())) { Utils.InsertPredicateSorted(transportRulePredicate, list); } } } foreach (TransportRulePredicate predicate in this.conditionsSetByParameters) { Utils.InsertPredicateSorted(predicate, list); } rule.Conditions = ((list.Count > 0) ? list.ToArray() : null); if (rule.Conditions == null) { base.WriteError(new ArgumentException(Strings.ErrorCannotCreateRuleWithoutCondition), ErrorCategory.InvalidArgument, this.Name); } } if (this.Exceptions != null) { rule.Exceptions = this.Exceptions; } else { List <TransportRulePredicate> list2 = new List <TransportRulePredicate>(); if (rule.Exceptions != null) { foreach (TransportRulePredicate transportRulePredicate2 in rule.Exceptions) { if (!this.exceptionTypesToUpdate.Contains(transportRulePredicate2.GetType())) { Utils.InsertPredicateSorted(transportRulePredicate2, list2); } } } foreach (TransportRulePredicate predicate2 in this.exceptionsSetByParameters) { Utils.InsertPredicateSorted(predicate2, list2); } if (list2.Count > 0) { rule.Exceptions = list2.ToArray(); } else { rule.Exceptions = null; } } if (this.policyObject != null) { rule.SetPolicyId(this.GetPolicyIdentity()); } }