コード例 #1
0
        public void SetOutboundConnector(IOutboundConnector configuration)
        {
            SessionParameters sessionParameters = this.BuildParameters(configuration);

            sessionParameters.Set("Identity", configuration.Identity.ToString());
            base.RemotePowershellSession.RunCommand("Set-OutboundConnector", sessionParameters);
        }
コード例 #2
0
        public IOutboundConnector NewOutboundConnector(IOutboundConnector configuration)
        {
            SessionParameters       parameters = this.BuildParameters(configuration);
            TenantOutboundConnector tenantOutboundConnector = base.RemotePowershellSession.RunOneCommandSingleResult <TenantOutboundConnector>("New-OutboundConnector", parameters, false);

            if (tenantOutboundConnector != null)
            {
                return(new OutboundConnector(tenantOutboundConnector));
            }
            return(null);
        }
コード例 #3
0
        private void ValidateFopeConnectorsAreUpgraded(ITaskContext taskContext)
        {
            IOrganizationConfig     organizationConfig     = base.OnPremisesSession.GetOrganizationConfig();
            IOnPremisesOrganization onPremisesOrganization = base.TenantSession.GetOnPremisesOrganization(organizationConfig.Guid);
            IInboundConnector       inboundConnector       = base.TenantSession.GetInboundConnector(onPremisesOrganization.InboundConnector.ToString());
            IOutboundConnector      outboundConnector      = base.TenantSession.GetOutboundConnector(onPremisesOrganization.OutboundConnector.ToString());

            if (inboundConnector.ConnectorSource != TenantConnectorSource.HybridWizard || outboundConnector.ConnectorSource != TenantConnectorSource.HybridWizard)
            {
                throw new LocalizedException(HybridStrings.ErrorHybridOnPremisesOrganizationWasNotCreatedWithUpgradedConnectors);
            }
        }
コード例 #4
0
        private SessionParameters BuildParameters(IOutboundConnector configuration)
        {
            SessionParameters sessionParameters = new SessionParameters();

            sessionParameters.Set("Name", configuration.Name);
            sessionParameters.Set <SmtpDomainWithSubdomains>("RecipientDomains", configuration.RecipientDomains);
            sessionParameters.Set <SmartHost>("SmartHosts", configuration.SmartHosts);
            sessionParameters.Set("ConnectorType", configuration.ConnectorType);
            sessionParameters.Set("TLSSettings", (Enum)configuration.TlsSettings);
            sessionParameters.Set("TLSDomain", configuration.TlsDomain);
            sessionParameters.Set("CloudServicesMailEnabled", configuration.CloudServicesMailEnabled);
            sessionParameters.Set("RouteAllMessagesViaOnPremises", configuration.RouteAllMessagesViaOnPremises);
            sessionParameters.Set("UseMxRecord", false);
            return(sessionParameters);
        }
コード例 #5
0
        private void UpgradeFopeConnectors(ITaskContext taskContext)
        {
            MultiValuedProperty <SmtpDomain> multiValuedProperty = new MultiValuedProperty <SmtpDomain>();

            foreach (SmtpDomain item in base.TaskContext.HybridConfigurationObject.Domains)
            {
                multiValuedProperty.Add(item);
            }
            IOrganizationConfig      organizationConfig        = base.OnPremisesSession.GetOrganizationConfig();
            List <string>            domains                   = new List <string>();
            OrganizationRelationship organizationRelationship  = TaskCommon.GetOrganizationRelationship(base.OnPremisesSession, Configuration.OnPremGetOrgRel, domains);
            OrganizationRelationship organizationRelationship2 = TaskCommon.GetOrganizationRelationship(base.TenantSession, Configuration.TenantGetOrgRel, domains);

            if (organizationRelationship2 == null || organizationRelationship == null)
            {
                throw new LocalizedException(HybridStrings.InvalidOrganizationRelationship);
            }
            string            onPremOrgRelationshipName = TaskCommon.GetOnPremOrgRelationshipName(organizationConfig);
            string            tenantOrgRelationshipName = TaskCommon.GetTenantOrgRelationshipName(organizationConfig);
            SessionParameters sessionParameters         = new SessionParameters();
            SessionParameters sessionParameters2        = new SessionParameters();

            sessionParameters.Set("Name", onPremOrgRelationshipName);
            sessionParameters2.Set("Name", tenantOrgRelationshipName);
            base.OnPremisesSession.SetOrganizationRelationship(organizationRelationship.Identity, sessionParameters);
            base.TenantSession.SetOrganizationRelationship(organizationRelationship2.Identity, sessionParameters2);
            organizationRelationship2 = TaskCommon.GetOrganizationRelationship(base.TenantSession, tenantOrgRelationshipName, domains);
            if (organizationRelationship2 == null)
            {
                throw new LocalizedException(HybridStrings.InvalidOrganizationRelationship);
            }
            IInboundConnector inboundConnector = base.TenantSession.GetInboundConnectors().FirstOrDefault((IInboundConnector x) => x.ConnectorSource == TenantConnectorSource.HybridWizard);

            if (inboundConnector == null)
            {
                throw new LocalizedException(HybridStrings.ErrorNoInboundConnector);
            }
            base.TenantSession.RenameInboundConnector(inboundConnector, Configuration.InboundConnectorName(organizationConfig.Guid.ToString()));
            IOutboundConnector outboundConnector = base.TenantSession.GetOutboundConnectors().FirstOrDefault((IOutboundConnector x) => x.ConnectorSource == TenantConnectorSource.HybridWizard);

            if (outboundConnector == null)
            {
                throw new LocalizedException(HybridStrings.ErrorNoOutboundConnector);
            }
            base.TenantSession.RenameOutboundConnector(outboundConnector, Configuration.OutboundConnectorName(organizationConfig.Guid.ToString()));
            base.TenantSession.NewOnPremisesOrganization(organizationConfig, multiValuedProperty, inboundConnector, outboundConnector, organizationRelationship2);
        }
コード例 #6
0
        /// <summary>
        /// Processes the required actions for an outbount connector.
        /// </summary>
        /// <param name="connector">The outbound connector to process.</param>
        private void ProcessOutboundConnector(IOutboundConnector connector)
        {
            this.Info("Outbound connector '{0}'-'{1}' is running.",
                      connector.ID, connector.Description);

            IConnection connection = null;

            do
            {
                if (connection != null)
                {
                    if (connection.IsConnected == false)
                    {
                        this.Info("Connection '{0}' of connector '{1}'-'{2}' has been closed.",
                                  connection.ID, connector.ID, connector.Description);

                        connection.Dispose();
                        connection = null;
                    }
                }

                if (connection == null)
                {
                    connection = connector.Connect();

                    if (connection != null)
                    {
                        _converterManager.CreateConverterStream(connection, _converterAssignments[connector.ID]);
                    }
                    else
                    {
                        this.Error("Creating outbound connection with connector '{0}'-'{1}' failed.",
                                   connector.ID, connector.Description);
                    }
                }
            }while (_shutdownEvent.WaitOne(ConnectionCheckInterval) == false);
        }
コード例 #7
0
        private bool DoTenantConnectorsNeedConfiguration()
        {
            this.onPremisesOrganizationOperation = MailFlowTask.Operation.NOP;
            this.inboundConnectorOperation       = MailFlowTask.Operation.NOP;
            this.outboundConnectorOperation      = MailFlowTask.Operation.NOP;
            this.onPremisesOrganization          = base.TenantSession.GetOnPremisesOrganization(this.OnPremOrgConfig.Guid);
            string identity  = this.DefaultInboundConnectorName;
            string identity2 = this.DefaultOutboundConnectorName;

            if (this.onPremisesOrganization == null)
            {
                this.onPremisesOrganizationOperation = MailFlowTask.Operation.New;
            }
            else
            {
                if (this.onPremisesOrganization.InboundConnector != null)
                {
                    identity = this.onPremisesOrganization.InboundConnector.ToString();
                }
                if (this.onPremisesOrganization.OutboundConnector != null)
                {
                    identity2 = this.onPremisesOrganization.OutboundConnector.ToString();
                }
            }
            this.inboundConnector = base.TenantSession.GetInboundConnector(identity);
            if (this.inboundConnector == null)
            {
                if (this.EnableSecureMail)
                {
                    this.inboundConnectorOperation = MailFlowTask.Operation.New;
                }
            }
            else if (this.EnableSecureMail)
            {
                IInboundConnector obj = this.BuildExpectedInboundConnector(null);
                if (!this.inboundConnector.Equals(obj))
                {
                    this.inboundConnectorOperation = MailFlowTask.Operation.Update;
                }
            }
            else
            {
                this.inboundConnectorOperation = MailFlowTask.Operation.Remove;
            }
            this.outboundConnector = base.TenantSession.GetOutboundConnector(identity2);
            if (this.outboundConnector == null)
            {
                if (this.EnableSecureMail)
                {
                    this.outboundConnectorOperation = MailFlowTask.Operation.New;
                }
            }
            else if (this.EnableSecureMail)
            {
                IOutboundConnector obj2 = this.BuildExpectedOutboundConnector(null);
                if (!this.outboundConnector.Equals(obj2))
                {
                    this.outboundConnectorOperation = MailFlowTask.Operation.Update;
                }
            }
            else
            {
                this.outboundConnectorOperation = MailFlowTask.Operation.Remove;
            }
            if (this.onPremisesOrganization != null)
            {
                ADObjectId b  = (this.inboundConnector == null) ? null : this.inboundConnector.Identity;
                ADObjectId b2 = (this.outboundConnector == null) ? null : this.outboundConnector.Identity;
                if (this.inboundConnectorOperation == MailFlowTask.Operation.New || this.inboundConnectorOperation == MailFlowTask.Operation.Remove || this.outboundConnectorOperation == MailFlowTask.Operation.New || this.outboundConnectorOperation == MailFlowTask.Operation.Remove || !TaskCommon.AreEqual(this.onPremisesOrganization.InboundConnector, b) || !TaskCommon.AreEqual(this.onPremisesOrganization.OutboundConnector, b2) || !TaskCommon.ContainsSame <SmtpDomain>(this.onPremisesOrganization.HybridDomains, this.HybridDomains) || !string.Equals(this.onPremisesOrganization.OrganizationName, this.OnPremOrgConfig.Name, StringComparison.InvariantCultureIgnoreCase) || !TaskCommon.AreEqual(this.onPremisesOrganization.OrganizationRelationship, (ADObjectId)this.TenantOrganizationRelationship.Identity))
                {
                    this.onPremisesOrganizationOperation = MailFlowTask.Operation.Update;
                }
            }
            return(this.onPremisesOrganizationOperation != MailFlowTask.Operation.NOP || this.inboundConnectorOperation != MailFlowTask.Operation.NOP || this.outboundConnectorOperation != MailFlowTask.Operation.NOP);
        }
コード例 #8
0
 public void RenameOutboundConnector(IOutboundConnector c, string name)
 {
     ((OutboundConnector)c).Name = name;
     this.SetOutboundConnector(c);
 }
コード例 #9
0
        public void SetOnPremisesOrganization(IOnPremisesOrganization configuration, IOrganizationConfig onPremisesOrgConfig, MultiValuedProperty <SmtpDomain> hybridDomains, IInboundConnector inboundConnector, IOutboundConnector outboundConnector, OrganizationRelationship tenantOrgRel)
        {
            Microsoft.Exchange.Management.Hybrid.Entity.OnPremisesOrganization onPremisesOrganization = (Microsoft.Exchange.Management.Hybrid.Entity.OnPremisesOrganization)configuration;
            onPremisesOrganization.HybridDomains            = hybridDomains;
            onPremisesOrganization.InboundConnector         = inboundConnector.Identity;
            onPremisesOrganization.OutboundConnector        = outboundConnector.Identity;
            onPremisesOrganization.OrganizationName         = onPremisesOrgConfig.Name;
            onPremisesOrganization.OrganizationRelationship = (ADObjectId)tenantOrgRel.Identity;
            SessionParameters sessionParameters = this.BuildParameters(configuration);

            sessionParameters.Set("Identity", configuration.Identity.ToString());
            base.RemotePowershellSession.RunCommand("Set-OnPremisesOrganization", sessionParameters);
        }
コード例 #10
0
        public IOnPremisesOrganization NewOnPremisesOrganization(IOrganizationConfig onPremisesOrgConfig, MultiValuedProperty <SmtpDomain> hybridDomains, IInboundConnector inboundConnector, IOutboundConnector outboundConnector, OrganizationRelationship tenantOrgRel)
        {
            Microsoft.Exchange.Management.Hybrid.Entity.OnPremisesOrganization onPremisesOrganization = new Microsoft.Exchange.Management.Hybrid.Entity.OnPremisesOrganization(onPremisesOrgConfig.Guid, onPremisesOrgConfig.Name, hybridDomains, inboundConnector.Identity, outboundConnector.Identity, onPremisesOrgConfig.Guid.ToString(), (ADObjectId)tenantOrgRel.Identity);
            SessionParameters sessionParameters = this.BuildParameters(onPremisesOrganization);

            sessionParameters.Set("Name", onPremisesOrganization.Name);
            sessionParameters.Set("OrganizationGuid", onPremisesOrganization.OrganizationGuid);
            Microsoft.Exchange.Data.Directory.SystemConfiguration.OnPremisesOrganization onPremisesOrganization2 = base.RemotePowershellSession.RunOneCommandSingleResult <Microsoft.Exchange.Data.Directory.SystemConfiguration.OnPremisesOrganization>("New-OnPremisesOrganization", sessionParameters, false);
            if (onPremisesOrganization2 != null)
            {
                return(new Microsoft.Exchange.Management.Hybrid.Entity.OnPremisesOrganization
                {
                    Identity = (ADObjectId)onPremisesOrganization2.Identity,
                    OrganizationGuid = onPremisesOrganization2.OrganizationGuid,
                    OrganizationName = onPremisesOrganization2.OrganizationName,
                    HybridDomains = onPremisesOrganization2.HybridDomains,
                    InboundConnector = onPremisesOrganization2.InboundConnector,
                    OutboundConnector = onPremisesOrganization2.OutboundConnector,
                    Name = onPremisesOrganization2.Name,
                    OrganizationRelationship = onPremisesOrganization2.OrganizationRelationship
                });
            }
            return(null);
        }