private void BuildExceptionsFromParameters(Microsoft.Exchange.MessagingPolicies.Rules.Tasks.Rule rule)
        {
            TypeMapping[] bridgeheadMappings   = TransportRulePredicate.BridgeheadMappings;
            List <TransportRulePredicate> list = new List <TransportRulePredicate>();

            this.exceptionTypesToUpdate = new List <Type>();
            if (base.Fields.IsModified(SupervisionPolicySchema.ClosedCampusOutboundGroupExceptions.Name))
            {
                RecipientIdParameter[] exceptIfFromMemberOf = rule.ExceptIfFromMemberOf;
                if (exceptIfFromMemberOf != null && exceptIfFromMemberOf.Length > 0)
                {
                    FromMemberOfPredicate fromMemberOfPredicate = new FromMemberOfPredicate();
                    fromMemberOfPredicate.Initialize(bridgeheadMappings);
                    fromMemberOfPredicate.Addresses = Utils.BuildSmtpAddressArray(exceptIfFromMemberOf, base.TenantGlobalCatalogSession);
                    Utils.InsertPredicateSorted(fromMemberOfPredicate, list);
                }
                this.exceptionTypesToUpdate.Add(typeof(FromMemberOfPredicate));
            }
            if (base.Fields.IsModified(SupervisionPolicySchema.ClosedCampusInboundGroupExceptions.Name))
            {
                RecipientIdParameter[] exceptIfSentToMemberOf = rule.ExceptIfSentToMemberOf;
                if (exceptIfSentToMemberOf != null && exceptIfSentToMemberOf.Length > 0)
                {
                    SentToMemberOfPredicate sentToMemberOfPredicate = new SentToMemberOfPredicate();
                    sentToMemberOfPredicate.Initialize(bridgeheadMappings);
                    sentToMemberOfPredicate.Addresses = Utils.BuildSmtpAddressArray(exceptIfSentToMemberOf, base.TenantGlobalCatalogSession);
                    Utils.InsertPredicateSorted(sentToMemberOfPredicate, list);
                }
                this.exceptionTypesToUpdate.Add(typeof(SentToMemberOfPredicate));
            }
            if (base.Fields.IsModified(SupervisionPolicySchema.ClosedCampusInboundDomainExceptions.Name))
            {
                Pattern[] exceptIfFromAddressMatchesPatterns = rule.ExceptIfFromAddressMatchesPatterns;
                if (exceptIfFromAddressMatchesPatterns != null && exceptIfFromAddressMatchesPatterns.Length > 0)
                {
                    FromAddressMatchesPredicate fromAddressMatchesPredicate = new FromAddressMatchesPredicate();
                    fromAddressMatchesPredicate.Initialize(bridgeheadMappings);
                    fromAddressMatchesPredicate.Patterns = exceptIfFromAddressMatchesPatterns;
                    Utils.InsertPredicateSorted(fromAddressMatchesPredicate, list);
                }
                this.exceptionTypesToUpdate.Add(typeof(FromAddressMatchesPredicate));
            }
            if (base.Fields.IsModified(SupervisionPolicySchema.ClosedCampusOutboundDomainExceptions.Name))
            {
                Pattern[] exceptIfRecipientAddressMatchesPatterns = rule.ExceptIfRecipientAddressMatchesPatterns;
                if (exceptIfRecipientAddressMatchesPatterns != null && exceptIfRecipientAddressMatchesPatterns.Length > 0)
                {
                    RecipientAddressMatchesPatternsPredicate recipientAddressMatchesPatternsPredicate = new RecipientAddressMatchesPatternsPredicate();
                    recipientAddressMatchesPatternsPredicate.Initialize(bridgeheadMappings);
                    recipientAddressMatchesPatternsPredicate.Patterns = exceptIfRecipientAddressMatchesPatterns;
                    Utils.InsertPredicateSorted(recipientAddressMatchesPatternsPredicate, list);
                }
                this.exceptionTypesToUpdate.Add(typeof(RecipientAddressMatchesPatternsPredicate));
            }
            this.exceptionsSetByParameters = list.ToArray();
        }
        private static SupervisionPolicy GetPresentationObject(ADRuleStorageManager storageManager, ref Dictionary <string, string> rules, bool displayDetails)
        {
            SupervisionPolicy supervisionPolicy = new SupervisionPolicy("SupervisionPolicy" + storageManager.RuleCollectionId.GetHashCode().ToString());

            foreach (Microsoft.Exchange.MessagingPolicies.Rules.Rule rule in storageManager.GetRuleCollection())
            {
                TransportRule transportRule = (TransportRule)rule;
                if (!transportRule.IsTooAdvancedToParse)
                {
                    Microsoft.Exchange.MessagingPolicies.Rules.Tasks.Rule rule2 = Microsoft.Exchange.MessagingPolicies.Rules.Tasks.Rule.CreateFromInternalRule(TransportRulePredicate.BridgeheadMappings, TransportRuleAction.BridgeheadMappings, transportRule, 0, null);
                    if (transportRule.Name.Equals(GetSupervisionPolicy.ClosedCampusInboundRuleName))
                    {
                        supervisionPolicy.ClosedCampusInboundPolicyEnabled = (transportRule.Enabled == RuleState.Enabled);
                        if (displayDetails)
                        {
                            supervisionPolicy.ClosedCampusInboundPolicyGroupExceptions  = GetSupervisionPolicy.ConvertToSmtpAddressMVP(rule2.ExceptIfSentToMemberOf);
                            supervisionPolicy.ClosedCampusInboundPolicyDomainExceptions = GetSupervisionPolicy.ConvertToSmtpDomains(rule2.ExceptIfFromAddressMatchesPatterns);
                        }
                        rules.Remove(GetSupervisionPolicy.ClosedCampusInboundRuleName);
                    }
                    else if (transportRule.Name.Equals(GetSupervisionPolicy.ClosedCampusOutboundRuleName))
                    {
                        supervisionPolicy.ClosedCampusOutboundPolicyEnabled = (transportRule.Enabled == RuleState.Enabled);
                        if (displayDetails)
                        {
                            supervisionPolicy.ClosedCampusOutboundPolicyGroupExceptions  = GetSupervisionPolicy.ConvertToSmtpAddressMVP(rule2.ExceptIfFromMemberOf);
                            supervisionPolicy.ClosedCampusOutboundPolicyDomainExceptions = GetSupervisionPolicy.ConvertToSmtpDomains(rule2.ExceptIfRecipientAddressMatchesPatterns);
                        }
                        rules.Remove(GetSupervisionPolicy.ClosedCampusOutboundRuleName);
                    }
                    else if (transportRule.Name.Equals(GetSupervisionPolicy.BadWordsRuleName))
                    {
                        supervisionPolicy.BadWordsPolicyEnabled = (transportRule.Enabled == RuleState.Enabled);
                        if (displayDetails)
                        {
                            supervisionPolicy.BadWordsList = GetSupervisionPolicy.ConvertToCommaSeparatedString(rule2.SubjectOrBodyContainsWords);
                        }
                        rules.Remove(GetSupervisionPolicy.BadWordsRuleName);
                    }
                    else if (transportRule.Name.Equals(GetSupervisionPolicy.AntiBullyingRuleName))
                    {
                        supervisionPolicy.AntiBullyingPolicyEnabled = (transportRule.Enabled == RuleState.Enabled);
                        rules.Remove(GetSupervisionPolicy.AntiBullyingRuleName);
                    }
                }
            }
            return(supervisionPolicy);
        }
        private void BuildConditionsFromParameters(Microsoft.Exchange.MessagingPolicies.Rules.Tasks.Rule rule)
        {
            TypeMapping[] bridgeheadMappings   = TransportRulePredicate.BridgeheadMappings;
            List <TransportRulePredicate> list = new List <TransportRulePredicate>();

            this.conditionTypesToUpdate = new List <Type>();
            if (base.Fields.IsModified(SupervisionPolicySchema.BadWordsList.Name))
            {
                Word[] subjectOrBodyContainsWords = rule.SubjectOrBodyContainsWords;
                if (subjectOrBodyContainsWords != null && subjectOrBodyContainsWords.Length > 0)
                {
                    SubjectOrBodyContainsPredicate subjectOrBodyContainsPredicate = new SubjectOrBodyContainsPredicate();
                    subjectOrBodyContainsPredicate.Initialize(bridgeheadMappings);
                    subjectOrBodyContainsPredicate.Words = subjectOrBodyContainsWords;
                    Utils.InsertPredicateSorted(subjectOrBodyContainsPredicate, list);
                }
                this.conditionTypesToUpdate.Add(typeof(SubjectOrBodyContainsPredicate));
            }
            this.conditionsSetByParameters = list.ToArray();
        }
Exemple #4
0
        public RuleRow(Microsoft.Exchange.MessagingPolicies.Rules.Tasks.Rule rule) : base(rule)
        {
            this.Name        = rule.Name;
            this.Priority    = rule.Priority;
            this.Enabled     = (rule.State == RuleState.Enabled);
            this.CaptionText = Strings.EditRuleCaption(rule.Name);
            this.DlpPolicy   = rule.DlpPolicy;
            this.RuleVersion = rule.RuleVersion;
            this.RuleMode    = rule.Mode.ToStringWithNull();
            int num = 0;

            num += ((!rule.From.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.SentTo.IsNullOrEmpty()) ? 1 : 0);
            num += ((rule.FromScope != null) ? 1 : 0);
            num += ((rule.SentToScope != null) ? 1 : 0);
            num += ((!rule.FromMemberOf.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.SentToMemberOf.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.SubjectOrBodyContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.FromAddressContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.RecipientAddressContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.AttachmentContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.AttachmentMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num += (rule.AttachmentIsUnsupported ? 1 : 0);
            num += ((!rule.SubjectOrBodyMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.FromAddressMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.RecipientAddressMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.AttachmentNameMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num += (rule.HasNoClassification ? 1 : 0);
            num += ((!rule.SubjectContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.SubjectMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.AnyOfToHeader.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.AnyOfToHeaderMemberOf.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.AnyOfCcHeader.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.AnyOfCcHeaderMemberOf.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.AnyOfToCcHeader.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.AnyOfToCcHeaderMemberOf.IsNullOrEmpty()) ? 1 : 0);
            num += ((rule.MessageTypeMatches != null) ? 1 : 0);
            num += ((rule.SenderManagementRelationship != null) ? 1 : 0);
            num += ((rule.WithImportance != null) ? 1 : 0);
            num += ((!rule.RecipientInSenderList.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.SenderInRecipientList.IsNullOrEmpty()) ? 1 : 0);
            num += ((rule.HeaderContainsMessageHeader != null && !rule.HeaderContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.BetweenMemberOf1.IsNullOrEmpty() && !rule.BetweenMemberOf2.IsNullOrEmpty()) ? 1 : 0);
            num += ((rule.HeaderMatchesMessageHeader != null && !rule.HeaderMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num += ((rule.ManagerForEvaluatedUser != null && !rule.ManagerAddresses.IsNullOrEmpty()) ? 1 : 0);
            num += ((rule.ADComparisonAttribute != null && rule.ADComparisonOperator != null) ? 1 : 0);
            num += ((rule.AttachmentSizeOver != null) ? 1 : 0);
            num += ((rule.SCLOver != null) ? 1 : 0);
            num += ((rule.HasClassification != null) ? 1 : 0);
            num += ((!rule.SenderADAttributeContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.SenderADAttributeMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.RecipientADAttributeContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.RecipientADAttributeMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num += ((rule.MessageSizeOver != null) ? 1 : 0);
            num += ((!rule.MessageContainsDataClassifications.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.AttachmentExtensionMatchesWords.IsNullOrEmpty()) ? 1 : 0);
            num += (rule.HasSenderOverride ? 1 : 0);
            num += (rule.AttachmentHasExecutableContent ? 1 : 0);
            num += ((rule.SenderIpRanges != null) ? 1 : 0);
            num += (rule.AttachmentProcessingLimitExceeded ? 1 : 0);
            num += ((!rule.SenderDomainIs.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.RecipientDomainIs.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.ContentCharacterSetContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num += (rule.AttachmentIsPasswordProtected ? 1 : 0);
            num += ((!rule.AnyOfRecipientAddressContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num += ((!rule.AnyOfRecipientAddressMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            int num2 = 0;

            num2 += ((!rule.ModerateMessageByUser.IsNullOrEmpty()) ? 1 : 0);
            num2 += ((!rule.RedirectMessageTo.IsNullOrEmpty()) ? 1 : 0);
            num2 += ((rule.RejectMessageReasonText != null || rule.SenderNotificationType != null) ? 1 : 0);
            num2 += (rule.DeleteMessage ? 1 : 0);
            num2 += ((!rule.BlindCopyTo.IsNullOrEmpty()) ? 1 : 0);
            num2 += ((rule.ApplyHtmlDisclaimerText != null) ? 1 : 0);
            num2 += ((rule.RemoveHeader != null) ? 1 : 0);
            num2 += ((!rule.AddToRecipients.IsNullOrEmpty()) ? 1 : 0);
            num2 += ((!rule.CopyTo.IsNullOrEmpty()) ? 1 : 0);
            num2 += (rule.ModerateMessageByManager ? 1 : 0);
            num2 += ((!string.IsNullOrEmpty(rule.PrependSubject)) ? 1 : 0);
            num2 += ((rule.AddManagerAsRecipientType != null) ? 1 : 0);
            num2 += ((rule.ApplyRightsProtectionTemplate != null) ? 1 : 0);
            num2 += ((rule.SetHeaderName != null && rule.SetHeaderValue != null) ? 1 : 0);
            num2 += ((rule.SetSCL != null) ? 1 : 0);
            num2 += ((rule.ApplyClassification != null) ? 1 : 0);
            num2 += (rule.StopRuleProcessing ? 1 : 0);
            num2 += ((!string.IsNullOrEmpty(rule.SetAuditSeverity)) ? 1 : 0);
            num2 += ((rule.GenerateIncidentReport != null) ? 1 : 0);
            num2 += (rule.RouteMessageOutboundRequireTls ? 1 : 0);
            num2 += (rule.ApplyOME ? 1 : 0);
            num2 += (rule.RemoveOME ? 1 : 0);
            num2 += (rule.Quarantine ? 1 : 0);
            num2 += ((rule.RouteMessageOutboundConnector != null) ? 1 : 0);
            num2 += ((rule.GenerateNotification != null) ? 1 : 0);
            int num3 = 0;

            num3          += ((!rule.ExceptIfFrom.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfSentTo.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((rule.ExceptIfFromScope != null) ? 1 : 0);
            num3          += ((rule.ExceptIfSentToScope != null) ? 1 : 0);
            num3          += ((!rule.ExceptIfFromMemberOf.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfSentToMemberOf.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfSubjectOrBodyContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfFromAddressContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfRecipientAddressContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfAttachmentContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfAttachmentMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num3          += (rule.ExceptIfAttachmentIsUnsupported ? 1 : 0);
            num3          += ((!rule.ExceptIfSubjectOrBodyMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfFromAddressMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfRecipientAddressMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfAttachmentNameMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num3          += (rule.ExceptIfHasNoClassification ? 1 : 0);
            num3          += ((!rule.ExceptIfSubjectContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfSubjectMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfAnyOfToHeader.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfAnyOfToHeaderMemberOf.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfAnyOfCcHeader.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfAnyOfCcHeaderMemberOf.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfAnyOfToCcHeader.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfAnyOfToCcHeaderMemberOf.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((rule.ExceptIfMessageTypeMatches != null) ? 1 : 0);
            num3          += ((rule.ExceptIfSenderManagementRelationship != null) ? 1 : 0);
            num3          += ((rule.ExceptIfWithImportance != null) ? 1 : 0);
            num3          += ((!rule.ExceptIfRecipientInSenderList.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfSenderInRecipientList.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((rule.ExceptIfHeaderContainsMessageHeader != null && !rule.ExceptIfHeaderContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfBetweenMemberOf1.IsNullOrEmpty() && !rule.ExceptIfBetweenMemberOf2.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((rule.ExceptIfHeaderMatchesMessageHeader != null && !rule.ExceptIfHeaderMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((rule.ExceptIfManagerForEvaluatedUser != null && !rule.ExceptIfManagerAddresses.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((rule.ExceptIfADComparisonAttribute != null && rule.ExceptIfADComparisonOperator != null) ? 1 : 0);
            num3          += ((rule.ExceptIfAttachmentSizeOver != null) ? 1 : 0);
            num3          += ((rule.ExceptIfSCLOver != null) ? 1 : 0);
            num3          += ((rule.ExceptIfHasClassification != null) ? 1 : 0);
            num3          += ((!rule.ExceptIfSenderADAttributeContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfSenderADAttributeMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfRecipientADAttributeContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfRecipientADAttributeMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((rule.ExceptIfMessageSizeOver != null) ? 1 : 0);
            num3          += ((!rule.ExceptIfMessageContainsDataClassifications.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfAttachmentExtensionMatchesWords.IsNullOrEmpty()) ? 1 : 0);
            num3          += (rule.ExceptIfHasSenderOverride ? 1 : 0);
            num3          += (rule.ExceptIfAttachmentHasExecutableContent ? 1 : 0);
            num3          += ((rule.ExceptIfSenderIpRanges != null) ? 1 : 0);
            num3          += (rule.ExceptIfAttachmentProcessingLimitExceeded ? 1 : 0);
            num3          += ((!rule.ExceptIfSenderDomainIs.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfRecipientDomainIs.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfContentCharacterSetContainsWords.IsNullOrEmpty()) ? 1 : 0);
            num3          += (rule.ExceptIfAttachmentIsPasswordProtected ? 1 : 0);
            num3          += ((!rule.ExceptIfAnyOfRecipientAddressMatchesPatterns.IsNullOrEmpty()) ? 1 : 0);
            num3          += ((!rule.ExceptIfAnyOfRecipientAddressContainsWords.IsNullOrEmpty()) ? 1 : 0);
            this.Supported = (num2 > 0 && !rule.Name.StartsWith("__", StringComparison.Ordinal) && num == (rule.Conditions.IsNullOrEmpty() ? 0 : rule.Conditions.Length) && num2 == (rule.Actions.IsNullOrEmpty() ? 0 : rule.Actions.Length) && num3 == (rule.Exceptions.IsNullOrEmpty() ? 0 : rule.Exceptions.Length));
        }
 private void UpdateRuleFromParameters(Microsoft.Exchange.MessagingPolicies.Rules.Tasks.Rule rule)
 {
     if (rule.Name.Equals(GetSupervisionPolicy.ClosedCampusInboundRuleName))
     {
         if (base.Fields.IsModified(SupervisionPolicySchema.ClosedCampusInboundPolicyEnabled.Name))
         {
             rule.State = (this.ClosedCampusInboundPolicyEnabled ? RuleState.Enabled : RuleState.Disabled);
         }
         if (base.Fields.IsModified(SupervisionPolicySchema.ClosedCampusInboundGroupExceptions.Name))
         {
             this.VerifyDistributionGroups(this.ClosedCampusInboundGroupExceptions, SupervisionPolicySchema.ClosedCampusInboundGroupExceptions.Name);
             rule.ExceptIfSentToMemberOf = ((this.ClosedCampusInboundGroupExceptions == null) ? null : this.ClosedCampusInboundGroupExceptions.ToArray());
         }
         if (base.Fields.IsModified(SupervisionPolicySchema.ClosedCampusInboundDomainExceptions.Name))
         {
             rule.ExceptIfFromAddressMatchesPatterns = this.ConvertToPatterns(this.ClosedCampusInboundDomainExceptions);
             return;
         }
     }
     else if (rule.Name.Equals(GetSupervisionPolicy.ClosedCampusOutboundRuleName))
     {
         if (base.Fields.IsModified(SupervisionPolicySchema.ClosedCampusOutboundPolicyEnabled.Name))
         {
             rule.State = (this.ClosedCampusOutboundPolicyEnabled ? RuleState.Enabled : RuleState.Disabled);
         }
         if (base.Fields.IsModified(SupervisionPolicySchema.ClosedCampusOutboundGroupExceptions.Name))
         {
             this.VerifyDistributionGroups(this.ClosedCampusOutboundGroupExceptions, SupervisionPolicySchema.ClosedCampusOutboundGroupExceptions.Name);
             rule.ExceptIfFromMemberOf = ((this.ClosedCampusOutboundGroupExceptions == null) ? null : this.ClosedCampusOutboundGroupExceptions.ToArray());
         }
         if (base.Fields.IsModified(SupervisionPolicySchema.ClosedCampusOutboundDomainExceptions.Name))
         {
             rule.ExceptIfRecipientAddressMatchesPatterns = this.ConvertToPatterns(this.ClosedCampusOutboundDomainExceptions);
             return;
         }
     }
     else if (rule.Name.Equals(GetSupervisionPolicy.BadWordsRuleName))
     {
         if (base.Fields.IsModified(SupervisionPolicySchema.BadWordsPolicyEnabled.Name))
         {
             if (this.BadWordsPolicyEnabled && ((base.Fields.IsModified(SupervisionPolicySchema.BadWordsList.Name) && string.IsNullOrEmpty(this.BadWordsList)) || (!base.Fields.IsModified(SupervisionPolicySchema.BadWordsList.Name) && rule.SubjectOrBodyContainsWords == null)))
             {
                 base.WriteError(new SupervisionPolicyTaskException(Strings.BadWordsPolicyNotEnabledIfBadWordsListNull), (ErrorCategory)1003, null);
             }
             rule.State = (this.BadWordsPolicyEnabled ? RuleState.Enabled : RuleState.Disabled);
         }
         if (base.Fields.IsModified(SupervisionPolicySchema.BadWordsList.Name))
         {
             Word[] array = this.ConvertFromCommaSeparatedStringToWords(this.BadWordsList);
             if ((string.IsNullOrEmpty(this.BadWordsList) || array.Length == 0) && ((base.Fields.IsModified(SupervisionPolicySchema.BadWordsPolicyEnabled.Name) && this.BadWordsPolicyEnabled) || (!base.Fields.IsModified(SupervisionPolicySchema.BadWordsPolicyEnabled.Name) && rule.State == RuleState.Enabled)))
             {
                 base.WriteError(new SupervisionPolicyTaskException(Strings.BadWordsPolicyNotEnabledIfBadWordsListNull), (ErrorCategory)1003, null);
             }
             rule.SubjectOrBodyContainsWords = array;
             return;
         }
     }
     else if (rule.Name.Equals(GetSupervisionPolicy.AntiBullyingRuleName) && base.Fields.IsModified(SupervisionPolicySchema.AntiBullyingPolicyEnabled.Name))
     {
         rule.State = (this.AntiBullyingPolicyEnabled ? RuleState.Enabled : RuleState.Disabled);
     }
 }
 private void UpdatePresentationObject(ref Microsoft.Exchange.MessagingPolicies.Rules.Tasks.Rule rule)
 {
     try
     {
         this.UpdateRuleFromParameters(rule);
         this.BuildConditionsFromParameters(rule);
         this.BuildExceptionsFromParameters(rule);
         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);
         }
         if (list.Count > 0)
         {
             rule.Conditions = list.ToArray();
         }
         else
         {
             rule.Conditions = null;
         }
         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;
         }
     }
     catch (ArgumentException exception)
     {
         base.WriteError(exception, ErrorCategory.InvalidArgument, null);
     }
     catch (RulesValidationException exception2)
     {
         base.WriteError(exception2, ErrorCategory.InvalidArgument, null);
     }
     catch (TransientException exception3)
     {
         base.WriteError(exception3, ErrorCategory.InvalidArgument, null);
     }
     catch (DataValidationException exception4)
     {
         base.WriteError(exception4, ErrorCategory.InvalidArgument, null);
     }
 }
        private static void UpdateRuleADObjectFromPresentationObject(SupervisionTransportRule adRuleObject, Microsoft.Exchange.MessagingPolicies.Rules.Tasks.Rule rule)
        {
            TransportRule rule2 = rule.ToInternalRule();
            string        xml   = TransportRuleSerializer.Instance.SaveRuleToString(rule2);

            adRuleObject.Xml = xml;
        }
 private void UpdateDataObject()
 {
     Microsoft.Exchange.MessagingPolicies.Rules.Tasks.Rule rule = SetSupervisionPolicy.ConvertFromRuleADObjectToPresentationObject(this.DataObject);
     this.UpdatePresentationObject(ref rule);
     SetSupervisionPolicy.UpdateRuleADObjectFromPresentationObject(this.DataObject, rule);
 }
 private void UpdateRuleState(SupervisionTransportRule supervisionTransportRule)
 {
     Microsoft.Exchange.MessagingPolicies.Rules.Tasks.Rule rule = SetSupervisionPolicy.ConvertFromRuleADObjectToPresentationObject(supervisionTransportRule);
     rule.State = (this.BadWordsPolicyEnabled ? RuleState.Enabled : RuleState.Disabled);
     SetSupervisionPolicy.UpdateRuleADObjectFromPresentationObject(supervisionTransportRule, rule);
 }