示例#1
0
            protected override void HandleNonAuthoritativeDomains(EmailAddressPolicy policy, HashSet <SmtpDomain> domains)
            {
                ProxyAddressTemplateCollection proxyAddressTemplateCollection = new ProxyAddressTemplateCollection();

                foreach (ProxyAddressTemplate proxyAddressTemplate in policy.NonAuthoritativeDomains)
                {
                    SmtpDomain smtpDomain;
                    if (!UpdateEmailAddressPolicy.DomainValidator.TryGetDomain(proxyAddressTemplate, out smtpDomain))
                    {
                        proxyAddressTemplateCollection.Add(proxyAddressTemplate);
                    }
                }
                bool flag = false;

                foreach (SmtpDomain smtpDomain2 in domains)
                {
                    SmtpProxyAddressTemplate item = new SmtpProxyAddressTemplate("@" + smtpDomain2.Domain, false);
                    proxyAddressTemplateCollection.Add(item);
                    if (!flag && !policy.NonAuthoritativeDomains.Contains(item))
                    {
                        flag = true;
                    }
                }
                if (!flag)
                {
                    flag = (proxyAddressTemplateCollection.Count != policy.NonAuthoritativeDomains.Count);
                }
                if (flag)
                {
                    UpdateEmailAddressPolicy.CheckEapVersion(policy);
                    policy.NonAuthoritativeDomains = proxyAddressTemplateCollection;
                }
            }
 protected override void WriteInvalidTemplate(SmtpProxyAddressTemplate template)
 {
     if (base.IsUsedBy(template))
     {
         base.ErrorWriter(new LocalizedException(Strings.AcceptedDomainIsReferencedByAddressTemplate(base.OldDomain.DomainName, template)), ErrorCategory.InvalidOperation, base.OldDomain.Identity);
     }
 }
示例#3
0
        private void AddTenantRoutingAddressToPolicy(EmailAddressPolicy policy)
        {
            List <ProxyAddressTemplate> list = new List <ProxyAddressTemplate>(policy.EnabledEmailAddressTemplates);
            SmtpProxyAddressTemplate    item = new SmtpProxyAddressTemplate("%m@" + this.tenantRoutingDomain, false);

            list.Add(item);
            ProxyAddressTemplateCollection enabledEmailAddressTemplates = new ProxyAddressTemplateCollection(list.ToArray());

            base.OnPremisesSession.SetEmailAddressPolicy(policy.DistinguishedName, null, enabledEmailAddressTemplates);
        }
示例#4
0
            protected static bool TryGetDomain(ProxyAddressTemplate template, out SmtpDomain domain)
            {
                SmtpProxyAddressTemplate smtpProxyAddressTemplate = template as SmtpProxyAddressTemplate;

                if (smtpProxyAddressTemplate != null)
                {
                    int    num     = smtpProxyAddressTemplate.AddressTemplateString.LastIndexOf('@');
                    string domain2 = smtpProxyAddressTemplate.AddressTemplateString.Substring(num + 1);
                    return(SmtpDomain.TryParse(domain2, out domain));
                }
                domain = null;
                return(false);
            }
示例#5
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);
        }
示例#6
0
 protected override void WriteInvalidTemplate(SmtpProxyAddressTemplate template)
 {
     if (this.oldDomain == null)
     {
         return;
     }
     if (!this.newDomain.IsChanged(AcceptedDomainSchema.AcceptedDomainType) || this.newDomain.DomainType != AcceptedDomainType.ExternalRelay)
     {
         return;
     }
     if (this.IsUsedBy(template))
     {
         this.ErrorWriter(new LocalizedException(Strings.CannotMakeAcceptedDomainExternalRelaySinceItIsReferencedByAddressTemplate(this.OldDomain.DomainName, template)), ErrorCategory.InvalidOperation, this.OldDomain.Identity);
     }
 }
示例#7
0
            protected override void HandleNonAuthoritativeDomains(EmailAddressPolicy policy, HashSet <SmtpDomain> domains)
            {
                ProxyAddressTemplateCollection proxyAddressTemplateCollection = new ProxyAddressTemplateCollection();

                foreach (ProxyAddressTemplate proxyAddressTemplate in policy.NonAuthoritativeDomains)
                {
                    SmtpDomain template;
                    if (!UpdateEmailAddressPolicy.DomainValidator.TryGetDomain(proxyAddressTemplate, out template) || (!SetAcceptedDomain.DomainEditValidator.Conflict(this.newDomain, template) && !SetAcceptedDomain.DomainEditValidator.Conflict(this.oldDomain, template)))
                    {
                        proxyAddressTemplateCollection.Add(proxyAddressTemplate);
                    }
                }
                foreach (SmtpDomain smtpDomain in domains)
                {
                    if (SetAcceptedDomain.DomainEditValidator.Conflict(this.newDomain, smtpDomain) || SetAcceptedDomain.DomainEditValidator.Conflict(this.oldDomain, smtpDomain))
                    {
                        SmtpProxyAddressTemplate item = new SmtpProxyAddressTemplate("@" + smtpDomain.Domain, false);
                        proxyAddressTemplateCollection.Add(item);
                    }
                }
                UpdateEmailAddressPolicy.CheckEapVersion(policy);
                policy.NonAuthoritativeDomains = proxyAddressTemplateCollection;
                this.session.Save(policy);
            }
示例#8
0
            protected bool IsUsedBy(SmtpProxyAddressTemplate template)
            {
                SmtpDomain template2;

                return(UpdateEmailAddressPolicy.DomainValidator.TryGetDomain(template, out template2) && SetAcceptedDomain.DomainEditValidator.Conflict(this.OldDomain, template2));
            }
示例#9
0
 protected override void WriteInvalidTemplate(SmtpProxyAddressTemplate template)
 {
     this.errorWriter(new ArgumentException(Strings.ErrorInvalidDomainInSmtpAddressTemplate(template)), ErrorCategory.InvalidData, template);
 }
示例#10
0
 protected override void WriteInvalidTemplate(SmtpProxyAddressTemplate template)
 {
     this.warningWriter(Strings.ErrorInvalidDomainInSmtpAddressTemplate(template));
 }
示例#11
0
 protected abstract void WriteInvalidTemplate(SmtpProxyAddressTemplate template);