예제 #1
0
 public static TransportRule ResolvePolicyRuleObject <T>(T policy, IConfigDataProvider session, string ruleCollectionName) where T : ADObject, new()
 {
     if (typeof(T) != typeof(MalwareFilterPolicy) && typeof(T) != typeof(HostedContentFilterPolicy))
     {
         throw new NotSupportedException();
     }
     try
     {
         ADRuleStorageManager adruleStorageManager = new ADRuleStorageManager(ruleCollectionName, session);
         adruleStorageManager.LoadRuleCollection();
         foreach (Rule rule in adruleStorageManager.GetRuleCollection())
         {
             TransportRule transportRule = (TransportRule)rule;
             if (transportRule.Actions != null && transportRule.Actions.Count > 0 && transportRule.Actions[0].Arguments != null && transportRule.Actions[0].Arguments.Count == 2)
             {
                 string strA = transportRule.Actions[0].Arguments[1].GetValue(null) as string;
                 if (string.Compare(strA, policy.Name, true) == 0)
                 {
                     return(transportRule);
                 }
             }
         }
     }
     catch (RuleCollectionNotInAdException)
     {
         return(null);
     }
     return(null);
 }
예제 #2
0
        private void BackupRulesForEheMigration()
        {
            ADRuleStorageManager adruleStorageManager = new ADRuleStorageManager(this.ruleCollectionName, base.DataSession);

            adruleStorageManager.LoadRuleCollection();
            this.transportRuleCollectionBackUp = adruleStorageManager.GetRuleCollection();
        }
예제 #3
0
        internal static ILookup <string, Microsoft.Exchange.MessagingPolicies.Rules.Rule> GetDataClassificationsInUse(IConfigDataProvider tenantSession, IEnumerable <string> dataClassificationIds, IEqualityComparer <string> dataClassificationIdComparer = null)
        {
            ArgumentValidator.ThrowIfNull("tenantSession", tenantSession);
            ArgumentValidator.ThrowIfNull("dataClassificationIds", dataClassificationIds);
            if (!dataClassificationIds.Any <string>())
            {
                return(Enumerable.Empty <Microsoft.Exchange.MessagingPolicies.Rules.Rule>().ToLookup((Microsoft.Exchange.MessagingPolicies.Rules.Rule rule) => null));
            }
            ADRuleStorageManager adruleStorageManager = new ADRuleStorageManager(Utils.RuleCollectionNameFromRole(), tenantSession);

            adruleStorageManager.LoadRuleCollection();
            return(DlpUtils.GetDataClassificationsReferencedByRuleCollection(adruleStorageManager.GetRuleCollection(), dataClassificationIds, dataClassificationIdComparer));
        }
        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);
        }