示例#1
0
        private IEnumerable <EmailAddressPolicy> GetEmailAddressPoliciesToUpdate(ITaskContext taskContext, bool verifyOnly, IEnumerable <string> hybridDomains, out bool legacyDefaultPolicyNeedsUpgrade)
        {
            List <EmailAddressPolicy> list = new List <EmailAddressPolicy>();

            legacyDefaultPolicyNeedsUpgrade = false;
            IEnumerable <EmailAddressPolicy> emailAddressPolicy = base.OnPremisesSession.GetEmailAddressPolicy();

            foreach (EmailAddressPolicy emailAddressPolicy2 in emailAddressPolicy)
            {
                bool flag  = false;
                bool flag2 = false;
                foreach (ProxyAddressTemplate proxyAddressTemplate in emailAddressPolicy2.EnabledEmailAddressTemplates)
                {
                    SmtpProxyAddressTemplate smtpProxyAddressTemplate = proxyAddressTemplate as SmtpProxyAddressTemplate;
                    if (!(smtpProxyAddressTemplate == null))
                    {
                        string proxyAddressTemplateString = smtpProxyAddressTemplate.ProxyAddressTemplateString;
                        int    num  = proxyAddressTemplateString.IndexOf("@");
                        string text = proxyAddressTemplateString.Substring(num + 1);
                        if (text.Equals(this.tenantRoutingDomain, StringComparison.InvariantCultureIgnoreCase))
                        {
                            flag2 = true;
                        }
                        else if (smtpProxyAddressTemplate.IsPrimaryAddress && hybridDomains.Contains(text, StringComparer.InvariantCultureIgnoreCase))
                        {
                            flag = true;
                        }
                    }
                }
                if (flag && !flag2)
                {
                    if (emailAddressPolicy2.RecipientFilterType == WellKnownRecipientFilterType.Legacy)
                    {
                        if (emailAddressPolicy2.Name.Equals("default policy", StringComparison.InvariantCultureIgnoreCase))
                        {
                            legacyDefaultPolicyNeedsUpgrade = true;
                            list.Add(emailAddressPolicy2);
                        }
                        else if (!verifyOnly)
                        {
                            taskContext.Warnings.Add(HybridStrings.WarningHybridLegacyEmailAddressPolicyNotUpgraded(emailAddressPolicy2.Name));
                        }
                    }
                    else
                    {
                        list.Add(emailAddressPolicy2);
                    }
                }
            }
            return(list);
        }