Ejemplo n.º 1
0
        private List <CommandParameter> GetOutboundConnectorParameters(bool isNew)
        {
            List <CommandParameter> list = new List <CommandParameter>();

            if (this.CentralizedTransportEnabled != null || this.OutboundDomains != null)
            {
                bool addWildcard = false;
                if (this.CentralizedTransportEnabled != null)
                {
                    addWildcard = this.CentralizedTransportEnabled.Value;
                }
                else if (base.OriginalInboundConnector != null && base.OriginalOutboundConnector != null)
                {
                    HybridMailflowConfiguration hybridMailflowConfiguration = HybridMailflowTaskBase.ConvertToHybridMailflowConfiguration(base.OriginalInboundConnector, base.OriginalOutboundConnector);
                    addWildcard = (hybridMailflowConfiguration.CentralizedTransportEnabled != null && hybridMailflowConfiguration.CentralizedTransportEnabled.Value);
                }
                if (this.OutboundDomains != null && HybridMailflowTaskBase.IsRecipientDomainsWildcard(this.OutboundDomains))
                {
                    addWildcard = true;
                }
                List <SmtpDomainWithSubdomains> value = (this.OutboundDomains != null) ? HybridMailflowTaskBase.GetRecipientDomains(this.OutboundDomains, addWildcard) : HybridMailflowTaskBase.GetRecipientDomains(base.OriginalOutboundConnector, addWildcard);
                list.Add(new CommandParameter("RecipientDomains", value));
            }
            if (this.CentralizedTransportEnabled != null && this.CentralizedTransportEnabled.Value)
            {
                list.Add(new CommandParameter("RouteAllMessagesViaOnPremises", this.CentralizedTransportEnabled.Value));
            }
            if (this.OnPremisesFQDN != null)
            {
                list.Add(new CommandParameter("SmartHosts", this.OnPremisesFQDN.ToString()));
                list.Add(new CommandParameter("UseMxRecord", false));
            }
            if (this.CertificateSubject != null)
            {
                list.Add(new CommandParameter("TlsDomain", this.CertificateSubject));
            }
            if (this.SecureMailEnabled != null)
            {
                list.Add(new CommandParameter("TlsSettings", this.SecureMailEnabled.Value ? new TlsAuthLevel?(TlsAuthLevel.DomainValidation) : null));
            }
            if (isNew)
            {
                if (base.OrganizationName != null)
                {
                    list.Add(new CommandParameter("Organization", base.OrganizationName));
                }
                list.Add(new CommandParameter("Name", "Hybrid Mail Flow Outbound Connector"));
                list.Add(new CommandParameter("Comment", Strings.HybridMailflowOutboundConnectorComment));
                list.Add(new CommandParameter("Enabled", true));
                list.Add(new CommandParameter("ConnectorType", "OnPremises"));
                list.Add(new CommandParameter("ConnectorSource", "HybridWizard"));
                list.Add(new CommandParameter("CloudServicesMailEnabled", true));
            }
            else
            {
                list.Add(new CommandParameter("Identity", base.OriginalOutboundConnector.Identity));
            }
            return(list);
        }
Ejemplo n.º 2
0
        private HybridMailflowConfiguration GetHybridMailflowSettingsFromMock()
        {
            HybridMailflowConfiguration result;

            if (base.Organization != null)
            {
                result = new HybridMailflowConfiguration(new List <SmtpDomainWithSubdomains>
                {
                    new SmtpDomainWithSubdomains("contoso.com"),
                    new SmtpDomainWithSubdomains("test.contoso.com")
                }, new List <IPRange>(), new Fqdn("mail.contoso.com"), "*.contoso.com", new bool?(false), new bool?(false));
            }
            else
            {
                result = new HybridMailflowConfiguration(new List <SmtpDomainWithSubdomains>(), new List <IPRange>(), new Fqdn("mail.fabrikam.com"), "*.fabrikam.com", new bool?(true), new bool?(false));
            }
            return(result);
        }
        protected static HybridMailflowConfiguration ConvertToHybridMailflowConfiguration(TenantInboundConnector inbound, TenantOutboundConnector outbound)
        {
            ArgumentValidator.ThrowIfNull("inbound", inbound);
            ArgumentValidator.ThrowIfNull("outbound", outbound);
            HybridMailflowConfiguration hybridMailflowConfiguration = new HybridMailflowConfiguration();

            hybridMailflowConfiguration.OutboundDomains = new List <SmtpDomainWithSubdomains>();
            foreach (SmtpDomainWithSubdomains smtpDomainWithSubdomains in outbound.RecipientDomains)
            {
                if (!HybridMailflowTaskBase.IsWildcardDomain(smtpDomainWithSubdomains))
                {
                    hybridMailflowConfiguration.OutboundDomains.Add(new SmtpDomainWithSubdomains(smtpDomainWithSubdomains.Address));
                }
            }
            if (inbound.SenderIPAddresses != null)
            {
                hybridMailflowConfiguration.InboundIPs = new List <IPRange>();
                foreach (IPRange item in inbound.SenderIPAddresses)
                {
                    hybridMailflowConfiguration.InboundIPs.Add(item);
                }
            }
            if (!MultiValuedPropertyBase.IsNullOrEmpty(outbound.SmartHosts))
            {
                SmartHost smartHost = outbound.SmartHosts[0];
                if (smartHost.IsIPAddress)
                {
                    hybridMailflowConfiguration.OnPremisesFQDN = new Fqdn(smartHost.Address.ToString());
                }
                else
                {
                    hybridMailflowConfiguration.OnPremisesFQDN = new Fqdn(smartHost.ToString());
                }
            }
            if (inbound.TlsSenderCertificateName != null)
            {
                hybridMailflowConfiguration.CertificateSubject = inbound.TlsSenderCertificateName.ToString();
            }
            hybridMailflowConfiguration.SecureMailEnabled           = new bool?(inbound.RequireTls && outbound.TlsSettings != null && outbound.TlsSettings == TlsAuthLevel.DomainValidation);
            hybridMailflowConfiguration.CentralizedTransportEnabled = new bool?((inbound.RestrictDomainsToIPAddresses && HybridMailflowTaskBase.IsRecipientDomainsWildcard(outbound.RecipientDomains)) || outbound.RouteAllMessagesViaOnPremises);
            return(hybridMailflowConfiguration);
        }