Beispiel #1
0
 public ExportTransportRuleCollection()
 {
     this.supportedPredicates = TransportRulePredicate.GetAvailablePredicateMappings();
     this.supportedActions    = TransportRuleAction.GetAvailableActionMappings();
     base.RuleCollectionName  = Utils.RuleCollectionNameFromRole();
     this.Format = RuleCollectionFormat.RuleCollectionXML;
 }
Beispiel #2
0
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "RightsProtectMessage")
            {
                return(null);
            }
            if (action.Arguments == null || action.Arguments.Count < 3)
            {
                return(null);
            }
            TransportRuleAction result;

            try
            {
                RightsProtectMessageAction rightsProtectMessageAction = new RightsProtectMessageAction();
                Guid   templateId  = new Guid(TransportRuleAction.GetStringValue(action.Arguments[1]));
                string stringValue = TransportRuleAction.GetStringValue(action.Arguments[2]);
                rightsProtectMessageAction.Template = new RmsTemplateIdentity(templateId, stringValue);
                result = rightsProtectMessageAction;
            }
            catch (FormatException)
            {
                result = null;
            }
            catch (OverflowException)
            {
                result = null;
            }
            return(result);
        }
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "SenderNotify" || !TransportRuleAction.GetStringValue(action.Arguments[1]).Equals("550"))
            {
                return(null);
            }
            NotifySenderAction notifySenderAction = new NotifySenderAction();

            try
            {
                notifySenderAction.SenderNotificationType = (NotifySenderType)Enum.Parse(typeof(NotifySenderType), TransportRuleAction.GetStringValue(action.Arguments[0]));
                notifySenderAction.EnhancedStatusCode     = new RejectEnhancedStatus(TransportRuleAction.GetStringValue(action.Arguments[2]));
                notifySenderAction.RejectReason           = new DsnText(TransportRuleAction.GetStringValue(action.Arguments[3]));
            }
            catch (ArgumentOutOfRangeException)
            {
                return(null);
            }
            catch (ArgumentException)
            {
                return(null);
            }
            catch (OverflowException)
            {
                return(null);
            }
            return(notifySenderAction);
        }
Beispiel #4
0
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "ModerateMessageByUser")
            {
                return(null);
            }
            List <SmtpAddress> list        = new List <SmtpAddress>();
            string             stringValue = TransportRuleAction.GetStringValue(action.Arguments[0]);

            string[] array = stringValue.Split(new string[]
            {
                ";"
            }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string text in array)
            {
                SmtpAddress item = new SmtpAddress(text.Trim());
                list.Add(item);
            }
            if (list.Count == 0)
            {
                return(null);
            }
            return(new ModerateMessageByUserAction
            {
                Addresses = list.ToArray()
            });
        }
Beispiel #5
0
 public GetTransportRule()
 {
     this.ruleCollectionName  = Utils.RuleCollectionNameFromRole();
     this.supportedPredicates = TransportRulePredicate.GetAvailablePredicateMappings();
     this.supportedActions    = TransportRuleAction.GetAvailableActionMappings();
     this.State = RuleState.Enabled;
     base.Fields.ResetChangeTracking();
 }
Beispiel #6
0
 internal static TransportRuleAction[] CreateAllAvailableActions(TypeMapping[] mappings, IConfigDataProvider session)
 {
     TransportRuleAction[] array = new TransportRuleAction[mappings.Length];
     for (int i = 0; i < mappings.Length; i++)
     {
         array[i] = TransportRuleAction.InternalCreateAction(mappings[i].Type, mappings, session);
     }
     return(array);
 }
Beispiel #7
0
 internal static bool TryCreateFromInternalAction(TypeMapping[] mappings, ShortList <Action> actions, ref int index, out TransportRuleAction taskAction, IConfigDataProvider session)
 {
     foreach (TypeMapping typeMapping in mappings)
     {
         MethodInfo method  = typeMapping.Type.GetMethod("CreateFromInternalActionWithSession", BindingFlags.Static | BindingFlags.NonPublic);
         MethodInfo method2 = typeMapping.Type.GetMethod("CreateFromInternalAction", BindingFlags.Static | BindingFlags.NonPublic);
         MethodInfo method3 = typeMapping.Type.GetMethod("CreateFromInternalActions", BindingFlags.Static | BindingFlags.NonPublic);
         if (method != null)
         {
             TransportRuleAction transportRuleAction = (TransportRuleAction)method.Invoke(null, new object[]
             {
                 actions[index],
                 session
             });
             if (transportRuleAction != null)
             {
                 index++;
                 taskAction = transportRuleAction;
                 taskAction.Initialize(mappings);
                 return(true);
             }
         }
         else if (method2 != null)
         {
             TransportRuleAction transportRuleAction = (TransportRuleAction)method2.Invoke(null, new object[]
             {
                 actions[index]
             });
             if (transportRuleAction != null)
             {
                 index++;
                 taskAction = transportRuleAction;
                 taskAction.Initialize(mappings);
                 return(true);
             }
         }
         else if (method3 != null)
         {
             object[] array = new object[]
             {
                 actions,
                 index
             };
             TransportRuleAction transportRuleAction = (TransportRuleAction)method3.Invoke(null, array);
             index = (int)array[1];
             if (transportRuleAction != null)
             {
                 taskAction = transportRuleAction;
                 taskAction.Initialize(mappings);
                 return(true);
             }
         }
     }
     taskAction = null;
     return(false);
 }
Beispiel #8
0
 internal static TransportRuleAction CreateAction(TypeMapping[] mappings, string name, IConfigDataProvider session)
 {
     foreach (TypeMapping typeMapping in mappings)
     {
         if (name.Equals(typeMapping.Name, StringComparison.OrdinalIgnoreCase))
         {
             return(TransportRuleAction.InternalCreateAction(typeMapping.Type, mappings, session));
         }
     }
     return(null);
 }
 internal static TransportRuleAction CreateFromInternalActionWithSession(Action action, IConfigDataProvider session)
 {
     if (action.Name != "SetHeaderUniqueValue" || TransportRuleAction.GetStringValue(action.Arguments[0]) != "X-MS-Exchange-Organization-Classification")
     {
         return(null);
     }
     return(new ApplyClassificationAction(session)
     {
         Classification = Utils.GetClassificationADObjectId(TransportRuleAction.GetStringValue(action.Arguments[1]), session)
     });
 }
		internal static TransportRuleAction CreateFromInternalAction(Action action)
		{
			if (action.Name != "RemoveHeader")
			{
				return null;
			}
			RemoveHeaderAction removeHeaderAction = new RemoveHeaderAction();
			try
			{
				removeHeaderAction.MessageHeader = new HeaderName(TransportRuleAction.GetStringValue(action.Arguments[0]));
			}
			catch (ArgumentOutOfRangeException)
			{
				return null;
			}
			return removeHeaderAction;
		}
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "RouteMessageOutboundConnector")
            {
                return(null);
            }
            RouteMessageOutboundConnectorAction routeMessageOutboundConnectorAction = new RouteMessageOutboundConnectorAction();

            try
            {
                routeMessageOutboundConnectorAction.ConnectorName = TransportRuleAction.GetStringValue(action.Arguments[0]);
            }
            catch (ArgumentOutOfRangeException)
            {
                return(null);
            }
            return(routeMessageOutboundConnectorAction);
        }
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "LogEvent")
            {
                return(null);
            }
            LogEventAction logEventAction = new LogEventAction();

            try
            {
                logEventAction.EventMessage = new EventLogText(TransportRuleAction.GetStringValue(action.Arguments[0]));
            }
            catch (ArgumentOutOfRangeException)
            {
                return(null);
            }
            return(logEventAction);
        }
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "PrependSubject")
            {
                return(null);
            }
            PrependSubjectAction prependSubjectAction = new PrependSubjectAction();

            try
            {
                prependSubjectAction.Prefix = new SubjectPrefix(TransportRuleAction.GetStringValue(action.Arguments[0]));
            }
            catch (ArgumentOutOfRangeException)
            {
                return(null);
            }
            return(prependSubjectAction);
        }
Beispiel #14
0
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "SetHeader")
            {
                return(null);
            }
            SetHeaderAction setHeaderAction = new SetHeaderAction();

            try
            {
                setHeaderAction.MessageHeader = new HeaderName(TransportRuleAction.GetStringValue(action.Arguments[0]));
                setHeaderAction.HeaderValue   = new HeaderValue(TransportRuleAction.GetStringValue(action.Arguments[1]));
            }
            catch (ArgumentOutOfRangeException)
            {
                return(null);
            }
            return(setHeaderAction);
        }
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "RejectMessage" || !TransportRuleAction.GetStringValue(action.Arguments[1]).Equals(SmtpRejectMessageAction.EnhancedStatusCode))
            {
                return(null);
            }
            SmtpRejectMessageAction smtpRejectMessageAction = new SmtpRejectMessageAction();

            try
            {
                smtpRejectMessageAction.StatusCode   = new RejectStatusCode(TransportRuleAction.GetStringValue(action.Arguments[0]));
                smtpRejectMessageAction.RejectReason = new RejectText(TransportRuleAction.GetStringValue(action.Arguments[2]));
            }
            catch (ArgumentOutOfRangeException)
            {
                return(null);
            }
            return(smtpRejectMessageAction);
        }
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "AuditSeverityLevel")
            {
                return(null);
            }
            SetAuditSeverityAction setAuditSeverityAction = new SetAuditSeverityAction();
            TransportRuleAction    result;

            try
            {
                setAuditSeverityAction.SeverityLevel = TransportRuleAction.GetStringValue(action.Arguments[0]);
                result = setAuditSeverityAction;
            }
            catch (ArgumentOutOfRangeException)
            {
                result = null;
            }
            return(result);
        }
Beispiel #17
0
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "GenerateNotification" || !action.Arguments.Any <Argument>())
            {
                return(null);
            }
            TransportRuleAction result;

            try
            {
                result = new GenerateNotificationAction(new DisclaimerText(TransportRuleAction.GetStringValue(action.Arguments[0])));
            }
            catch (ArgumentOutOfRangeException)
            {
                result = null;
            }
            catch (ArgumentException)
            {
                result = null;
            }
            return(result);
        }
Beispiel #18
0
        protected override void InternalProcessRecord()
        {
            TypeMapping[]       availableActionMappings = TransportRuleAction.GetAvailableActionMappings();
            IConfigDataProvider session = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 47, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\TransportRule\\GetTransportRuleAction.cs");

            if (string.IsNullOrEmpty(this.name))
            {
                foreach (TransportRuleAction sendToPipeline in TransportRuleAction.CreateAllAvailableActions(availableActionMappings, session))
                {
                    base.WriteObject(sendToPipeline);
                }
                return;
            }
            TransportRuleAction transportRuleAction = TransportRuleAction.CreateAction(availableActionMappings, this.name, session);

            if (transportRuleAction == null)
            {
                base.WriteError(new ArgumentException(Strings.InvalidAction, "Name"), ErrorCategory.InvalidArgument, this.Name);
                return;
            }
            base.WriteObject(transportRuleAction);
        }
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "GenerateIncidentReport" || action.Arguments.Count == 0)
            {
                return(null);
            }
            GenerateIncidentReportAction generateIncidentReportAction = new GenerateIncidentReportAction();
            string stringValue = TransportRuleAction.GetStringValue(action.Arguments[0]);

            if (!SmtpAddress.IsValidSmtpAddress(stringValue))
            {
                return(null);
            }
            generateIncidentReportAction.ReportDestination = new SmtpAddress(stringValue);
            IncidentReportOriginalMail legacyReportOriginalMail;

            if (action.Arguments.Count == 2 && GenerateIncidentReport.TryGetIncidentReportOriginalMailParameter(TransportRuleAction.GetStringValue(action.Arguments[1]), out legacyReportOriginalMail))
            {
                generateIncidentReportAction.IncidentReportContent = GenerateIncidentReport.GetLegacyContentItems(legacyReportOriginalMail).ToArray();
            }
            else
            {
                for (int i = 1; i < action.Arguments.Count; i++)
                {
                    IncidentReportContent contentItem;
                    if (Enum.TryParse <IncidentReportContent>(TransportRuleAction.GetStringValue(action.Arguments[i]), out contentItem))
                    {
                        generateIncidentReportAction.AddIncidentReportContentItem(contentItem);
                    }
                }
                if (generateIncidentReportAction.IncidentReportContent.Length == 0)
                {
                    generateIncidentReportAction.AddIncidentReportContentItem(Microsoft.Exchange.MessagingPolicies.Rules.IncidentReportContent.RuleDetections);
                }
            }
            generateIncidentReportAction.IncidentReportOriginalMail = (generateIncidentReportAction.IncidentReportContent.Contains(Microsoft.Exchange.MessagingPolicies.Rules.IncidentReportContent.AttachOriginalMail) ? IncidentReportOriginalMail.IncludeOriginalMail : IncidentReportOriginalMail.DoNotIncludeOriginalMail);
            return(generateIncidentReportAction);
        }
Beispiel #20
0
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "RejectMessage" || !TransportRuleAction.GetStringValue(action.Arguments[0]).Equals("550"))
            {
                return(null);
            }
            RejectMessageAction rejectMessageAction = new RejectMessageAction();

            try
            {
                rejectMessageAction.RejectReason       = new DsnText(TransportRuleAction.GetStringValue(action.Arguments[2]));
                rejectMessageAction.EnhancedStatusCode = new RejectEnhancedStatus(TransportRuleAction.GetStringValue(action.Arguments[1]));
            }
            catch (ArgumentOutOfRangeException)
            {
                return(null);
            }
            catch (ArgumentException)
            {
                return(null);
            }
            return(rejectMessageAction);
        }
Beispiel #21
0
        internal static TransportRuleAction CreateFromInternalActions <T>(ShortList <Action> actions, ref int index, string internalActionName) where T : SmtpAddressAction, new()
        {
            List <SmtpAddress> list = new List <SmtpAddress>();

            while (index < actions.Count && !(actions[index].Name != internalActionName))
            {
                SmtpAddress item = new SmtpAddress(TransportRuleAction.GetStringValue(actions[index].Arguments[0]));
                if (!item.IsValidAddress)
                {
                    break;
                }
                list.Add(item);
                index++;
            }
            if (list.Count == 0)
            {
                return(null);
            }
            T t = Activator.CreateInstance <T>();

            t.Addresses = list.ToArray();
            return(t);
        }
Beispiel #22
0
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "SetHeader" || TransportRuleAction.GetStringValue(action.Arguments[0]) != "X-MS-Exchange-Organization-SCL")
            {
                return(null);
            }
            int input;

            if (!int.TryParse(TransportRuleAction.GetStringValue(action.Arguments[1]), out input))
            {
                return(null);
            }
            SetSclAction setSclAction = new SetSclAction();

            try
            {
                setSclAction.SclValue = new SclValue(input);
            }
            catch (ArgumentOutOfRangeException)
            {
                return(null);
            }
            return(setSclAction);
        }
Beispiel #23
0
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "ApplyHtmlDisclaimer")
            {
                return(null);
            }
            DisclaimerLocation       location;
            DisclaimerText           text2;
            DisclaimerFallbackAction disclaimerFallbackAction;

            try
            {
                string text = TransportRuleAction.GetStringValue(action.Arguments[0]);
                if (text.Equals("Inline", StringComparison.InvariantCultureIgnoreCase))
                {
                    text = "Append";
                }
                location = (DisclaimerLocation)Enum.Parse(typeof(DisclaimerLocation), text);
                text2    = new DisclaimerText(TransportRuleAction.GetStringValue(action.Arguments[1]));
                disclaimerFallbackAction = (DisclaimerFallbackAction)Enum.Parse(typeof(DisclaimerFallbackAction), TransportRuleAction.GetStringValue(action.Arguments[2]));
            }
            catch (ArgumentException)
            {
                return(null);
            }
            catch (OverflowException)
            {
                return(null);
            }
            return(new ApplyHtmlDisclaimerAction
            {
                Location = location,
                Text = text2,
                FallbackAction = disclaimerFallbackAction
            });
        }
Beispiel #24
0
        protected override void InternalValidate()
        {
            base.InternalValidate();
            TransportRule dataObject = this.DataObject;

            if (dataObject == null)
            {
                ExAssert.RetailAssert(false, "EnableTransportRule.InternalValidate data object is invalid");
            }
            TransportRule rule  = (TransportRule)TransportRuleParser.Instance.GetRule(dataObject.Xml);
            Rule          rule2 = Rule.CreateFromInternalRule(TransportRulePredicate.GetAvailablePredicateMappings(), TransportRuleAction.GetAvailableActionMappings(), rule, dataObject.Priority, dataObject);
            IEnumerable <RightsProtectMessageAction> source = (from action in rule2.Actions
                                                               where action is RightsProtectMessageAction
                                                               select action as RightsProtectMessageAction).ToList <RightsProtectMessageAction>();

            if (source.Any <RightsProtectMessageAction>())
            {
                if (!RmsClientManager.IRMConfig.IsInternalLicensingEnabledForTenant(base.CurrentOrganizationId))
                {
                    base.WriteError(new IrmLicensingIsDisabledException(), ErrorCategory.InvalidArgument, null);
                }
                RmsTemplateIdentity     template = source.First <RightsProtectMessageAction>().Template;
                RmsTemplateDataProvider session  = new RmsTemplateDataProvider((IConfigurationSession)base.DataSession);
                base.GetDataObject <RmsTemplatePresentation>(new RmsTemplateIdParameter(template), session, null, new LocalizedString?(Strings.OutlookProtectionRuleRmsTemplateNotFound(template.TemplateName)), new LocalizedString?(Strings.OutlookProtectionRuleRmsTemplateNotUnique(template.TemplateName)));
            }
            bool flag;

            if (!rule2.Actions.Any((TransportRuleAction action) => action is ApplyOMEAction))
            {
                flag = rule2.Actions.Any((TransportRuleAction action) => action is RemoveOMEAction);
            }
            else
            {
                flag = true;
            }
            bool flag2 = flag;

            if (flag2)
            {
                IRMConfiguration irmconfiguration = IRMConfiguration.Read((IConfigurationSession)base.DataSession);
                if (irmconfiguration == null || !irmconfiguration.InternalLicensingEnabled)
                {
                    base.WriteError(new E4eLicensingIsDisabledExceptionEnableRule(), ErrorCategory.InvalidArgument, null);
                }
                if (RmsClientManager.IRMConfig.GetRmsTemplate(base.CurrentOrganizationId, RmsTemplate.InternetConfidential.Id) == null)
                {
                    base.WriteError(new E4eRuleRmsTemplateNotFoundException(RmsTemplate.InternetConfidential.Name), ErrorCategory.InvalidArgument, null);
                }
            }
        }
        internal static TransportRuleAction CreateFromInternalAction(Action action)
        {
            if (action.Name != "AddManagerAsRecipientType")
            {
                return(null);
            }
            AddedRecipientType recipientType;

            try
            {
                recipientType = (AddedRecipientType)Enum.Parse(typeof(AddedRecipientType), TransportRuleAction.GetStringValue(action.Arguments[0]));
            }
            catch (ArgumentException)
            {
                return(null);
            }
            catch (OverflowException)
            {
                return(null);
            }
            return(new AddManagerAsRecipientTypeAction
            {
                RecipientType = recipientType
            });
        }