コード例 #1
0
        public IFederationInformation GetFederationInformation(string domainName)
        {
            SessionParameters sessionParameters = new SessionParameters();

            sessionParameters.Set("DomainName", domainName);
            sessionParameters.Set("BypassAdditionalDomainValidation", true);
            Dictionary <string, object> dictionary = null;

            try
            {
                dictionary = this.RemotePowershellSession.GetPowershellUntypedObjectAsMembers("Get-FederationInformation", null, sessionParameters);
            }
            catch
            {
            }
            if (dictionary != null)
            {
                FederationInformation federationInformation = new FederationInformation();
                object value;
                if (dictionary.TryGetValue("TargetAutodiscoverEpr", out value))
                {
                    federationInformation.TargetAutodiscoverEpr = TaskCommon.ToStringOrNull(value);
                }
                if (dictionary.TryGetValue("TargetApplicationUri", out value))
                {
                    federationInformation.TargetApplicationUri = TaskCommon.ToStringOrNull(value);
                }
                return(federationInformation);
            }
            return(null);
        }
コード例 #2
0
        private SessionParameters BuildParameters(IOnPremisesOrganization configuration)
        {
            SessionParameters sessionParameters = new SessionParameters();

            sessionParameters.Set <SmtpDomain>("HybridDomains", configuration.HybridDomains, (SmtpDomain d) => d.Domain);
            sessionParameters.Set("InboundConnector", TaskCommon.ToStringOrNull(configuration.InboundConnector));
            sessionParameters.Set("OutboundConnector", TaskCommon.ToStringOrNull(configuration.OutboundConnector));
            sessionParameters.Set("OrganizationRelationship", TaskCommon.ToStringOrNull(configuration.OrganizationRelationship));
            sessionParameters.Set("OrganizationName", configuration.OrganizationName);
            return(sessionParameters);
        }
コード例 #3
0
 public IExchangeCertificate GetExchangeCertificate(string server, SmtpX509Identifier certificateName)
 {
     foreach (IExchangeCertificate exchangeCertificate in this.GetExchangeCertificate(server))
     {
         if (TaskCommon.AreEqual(exchangeCertificate.Identifier, certificateName))
         {
             return(exchangeCertificate);
         }
     }
     return(null);
 }
コード例 #4
0
        private bool TaskConfigure(ITaskContext taskContext)
        {
            IOrganizationConfig organizationConfig = taskContext.TenantSession.GetOrganizationConfig();

            if (organizationConfig.IsDehydrated)
            {
                try
                {
                    taskContext.TenantSession.EnableOrganizationCustomization();
                }
                catch
                {
                }
            }
            if (this.RequiresFederationTrust())
            {
                if (this.updateOnPremisesFedOrgId)
                {
                    IFederatedOrganizationIdentifier federatedOrganizationIdentifier = base.OnPremisesSession.GetFederatedOrganizationIdentifier();
                    string text = (federatedOrganizationIdentifier != null && federatedOrganizationIdentifier.DelegationTrustLink != null) ? federatedOrganizationIdentifier.DelegationTrustLink.ToString() : Configuration.FederatedTrustIdentity;
                    taskContext.OnPremisesSession.SetFederationTrustRefreshMetadata(text);
                    SmtpDomain autoDiscoverHybridDomain = this.AutoDiscoverHybridDomain;
                    string     defaultDomain            = (autoDiscoverHybridDomain != null && autoDiscoverHybridDomain.Domain != null) ? autoDiscoverHybridDomain.Domain : null;
                    taskContext.OnPremisesSession.SetFederatedOrganizationIdentifier(this.accountNamespace, text, defaultDomain);
                }
                List <Uri> acceptedTokenIssuerUris = taskContext.Parameters.Get <List <Uri> >("_onPremAcceptedTokenIssuerUris");
                if (!OrganizationRelationshipTask.VerifyAcceptedTokenIssuerUri(base.OnPremisesSession, acceptedTokenIssuerUris))
                {
                    throw new LocalizedException(HybridStrings.ErrorOnPremUsingConsumerLiveID);
                }
                acceptedTokenIssuerUris = taskContext.Parameters.Get <List <Uri> >("_tenantAcceptedTokenIssuerUris");
                if (!OrganizationRelationshipTask.VerifyAcceptedTokenIssuerUri(base.TenantSession, acceptedTokenIssuerUris))
                {
                    throw new LocalizedException(HybridStrings.ErrorTenantUsingConsumerLiveID);
                }
                if (this.updateTenantFedOrgId)
                {
                    base.TenantSession.SetFederatedOrganizationIdentifier(this.TenantCoexistenceDomain);
                }
                foreach (string domainName in this.addOnPremisesFedDomains)
                {
                    taskContext.OnPremisesSession.AddFederatedDomain(domainName);
                }
            }
            OrganizationRelationship value = OrganizationRelationshipTask.ProvisionOrganizationRelationship(base.OnPremisesSession, taskContext.Parameters.Get <OrganizationRelationship>("_onPremOrgRel"), this.OnpremisesFederationInfo, new SmtpDomain[]
            {
                new SmtpDomain(this.TenantCoexistenceDomain)
            }, TaskCommon.GetOnPremOrgRelationshipName(this.OnPremOrgConfig));

            taskContext.Parameters.Set <OrganizationRelationship>("_onPremOrgRel", value);
            value = OrganizationRelationshipTask.ProvisionOrganizationRelationship(base.TenantSession, taskContext.Parameters.Get <OrganizationRelationship>("_tenantOrgRel"), this.TenantFederationInfo, this.HybridDomains, TaskCommon.GetTenantOrgRelationshipName(this.OnPremOrgConfig));
            taskContext.Parameters.Set <OrganizationRelationship>("_tenantOrgRel", value);
            return(true);
        }
コード例 #5
0
        public override bool NeedsConfiguration(ITaskContext taskContext)
        {
            bool flag = base.NeedsConfiguration(taskContext);
            OrganizationRelationship existingOrgRel  = taskContext.Parameters.Get <OrganizationRelationship>("_onPremOrgRel");
            OrganizationRelationship existingOrgRel2 = taskContext.Parameters.Get <OrganizationRelationship>("_tenantOrgRel");

            return(flag || this.NeedProvisionOrganizationRelationship(base.OnPremisesSession, existingOrgRel, this.OnpremisesFederationInfo, new SmtpDomain[]
            {
                new SmtpDomain(this.TenantCoexistenceDomain)
            }, TaskCommon.GetOnPremOrgRelationshipName(this.OnPremOrgConfig)) || this.NeedProvisionOrganizationRelationship(base.TenantSession, existingOrgRel2, this.TenantFederationInfo, this.HybridDomains, TaskCommon.GetTenantOrgRelationshipName(this.OnPremOrgConfig)) || (this.RequiresFederationTrust() && (this.updateOnPremisesFedOrgId || this.updateTenantFedOrgId || this.addOnPremisesFedDomains.Count > 0)));
        }
コード例 #6
0
        public void SetReceiveConnector(IReceiveConnector configuration)
        {
            SessionParameters sessionParameters = new SessionParameters();

            if (configuration.Identity != null)
            {
                sessionParameters.Set("Identity", configuration.Identity.ToString());
            }
            sessionParameters.Set("TLSCertificateName", TaskCommon.ToStringOrNull(configuration.TlsCertificateName));
            sessionParameters.Set("TLSDomainCapabilities", TaskCommon.ToStringOrNull(configuration.TlsDomainCapabilities));
            base.RemotePowershellSession.RunOneCommand("Set-ReceiveConnector", sessionParameters, false);
        }
コード例 #7
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);
        }
コード例 #8
0
        private SessionParameters SetSendConnectorParameters(ISendConnector configuration)
        {
            SessionParameters sessionParameters = new SessionParameters();

            sessionParameters.Set("Name", configuration.Name);
            sessionParameters.Set <AddressSpace>("AddressSpaces", configuration.AddressSpaces);
            sessionParameters.Set <ADObjectId>("SourceTransportServers", configuration.SourceTransportServers);
            sessionParameters.Set("DNSRoutingEnabled", configuration.DNSRoutingEnabled);
            sessionParameters.Set <SmartHost>("SmartHosts", configuration.SmartHosts);
            sessionParameters.Set("TLSDomain", configuration.TlsDomain);
            sessionParameters.Set("RequireTLS", configuration.RequireTLS);
            sessionParameters.Set("TLSAuthLevel", (Enum)configuration.TlsAuthLevel);
            sessionParameters.Set("ErrorPolicies", configuration.ErrorPolicies);
            sessionParameters.Set("TLSCertificateName", TaskCommon.ToStringOrNull(configuration.TlsCertificateName));
            sessionParameters.Set("CloudServicesMailEnabled", configuration.CloudServicesMailEnabled);
            sessionParameters.Set("Fqdn", configuration.Fqdn);
            return(sessionParameters);
        }
コード例 #9
0
        private static OrganizationRelationship ProvisionOrganizationRelationship(ICommonSession session, OrganizationRelationship existingOrgRel, IFederationInformation federationInfo, IEnumerable <SmtpDomain> domains, string relationshipName)
        {
            if (existingOrgRel != null)
            {
                session.RemoveOrganizationRelationship(existingOrgRel.Identity.ToString());
            }
            string targetApplicationUri  = (federationInfo != null) ? federationInfo.TargetApplicationUri : null;
            string targetAutodiscoverEpr = (federationInfo != null) ? federationInfo.TargetAutodiscoverEpr : null;

            session.NewOrganizationRelationship(relationshipName, targetApplicationUri, targetAutodiscoverEpr, domains);
            existingOrgRel = TaskCommon.GetOrganizationRelationship(session, relationshipName, from d in domains
                                                                    select d.Domain);
            if (existingOrgRel == null)
            {
                throw new LocalizedException(HybridStrings.ErrorOrgRelProvisionFailed(domains.First <SmtpDomain>().ToString()));
            }
            return(existingOrgRel);
        }
コード例 #10
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);
        }
コード例 #11
0
 private bool NeedProvisionOrganizationRelationship(ICommonSession session, OrganizationRelationship existingOrgRel, IFederationInformation federationInfo, IEnumerable <SmtpDomain> domains, string relationshipName)
 {
     return(existingOrgRel == null || !TaskCommon.ContainsSame <SmtpDomain>(existingOrgRel.DomainNames, domains) || (this.RequiresFederationTrust() && (!string.Equals(TaskCommon.ToStringOrNull(existingOrgRel.TargetApplicationUri), federationInfo.TargetApplicationUri, StringComparison.InvariantCultureIgnoreCase) || !string.Equals(TaskCommon.ToStringOrNull(existingOrgRel.TargetAutodiscoverEpr), federationInfo.TargetAutodiscoverEpr, StringComparison.InvariantCultureIgnoreCase))));
 }
コード例 #12
0
 private bool CheckTaskPrerequisites(ITaskContext taskContext)
 {
     this.Reset();
     if (this.RequiresFederationTrust())
     {
         string value = Configuration.SignupDomainSuffix(taskContext.HybridConfigurationObject.ServiceInstance);
         foreach (AutoDiscoverSmtpDomain autoDiscoverSmtpDomain in this.HybridDomains)
         {
             if (!autoDiscoverSmtpDomain.Domain.EndsWith(value, StringComparison.InvariantCultureIgnoreCase) && autoDiscoverSmtpDomain.Domain.Length <= 32)
             {
                 this.accountNamespace = autoDiscoverSmtpDomain.Domain;
                 break;
             }
         }
         if (string.IsNullOrEmpty(this.accountNamespace))
         {
             base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, HybridStrings.ErrorAccountNamespace));
             base.AddLocalizedStringError(HybridStrings.ErrorAccountNamespace);
             return(false);
         }
         int num = base.OnPremisesSession.GetFederationTrust().Count <IFederationTrust>();
         if (num == 0)
         {
             base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, Strings.ErrorFederationTrustNotFound("")));
             base.AddLocalizedStringError(HybridStrings.ErrorNoFederationTrustFound);
             return(false);
         }
         if (num > 1)
         {
             base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, HybridStrings.ErrorMultipleFederationTrusts));
             base.AddLocalizedStringError(HybridStrings.ErrorMultipleFederationTrusts);
             return(false);
         }
         IFederatedOrganizationIdentifier federatedOrganizationIdentifier = base.OnPremisesSession.GetFederatedOrganizationIdentifier();
         if (federatedOrganizationIdentifier == null)
         {
             this.updateOnPremisesFedOrgId = true;
         }
         else if (federatedOrganizationIdentifier.AccountNamespace == null || string.IsNullOrEmpty(federatedOrganizationIdentifier.AccountNamespace.Domain))
         {
             this.updateOnPremisesFedOrgId = true;
         }
         else
         {
             if (!federatedOrganizationIdentifier.Enabled)
             {
                 base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, HybridStrings.ErrorFederatedIdentifierDisabled));
                 base.AddLocalizedStringError(HybridStrings.ErrorFederatedIdentifierDisabled);
                 return(false);
             }
             this.accountNamespace = federatedOrganizationIdentifier.AccountNamespace.Domain.Replace(FederatedOrganizationId.HybridConfigurationWellKnownSubDomain + ".", string.Empty);
             if (!string.Equals(TaskCommon.ToStringOrNull(federatedOrganizationIdentifier.DelegationTrustLink), Configuration.FederatedTrustIdentity))
             {
                 this.updateOnPremisesFedOrgId = true;
             }
             else
             {
                 this.updateOnPremisesFedOrgId = false;
                 using (IEnumerator <string> enumerator2 = (from d in this.HybridDomains
                                                            select d.Domain).GetEnumerator())
                 {
                     while (enumerator2.MoveNext())
                     {
                         string hybridDomain = enumerator2.Current;
                         if (!federatedOrganizationIdentifier.Domains.Any((FederatedDomain d) => string.Equals(d.Domain.Domain, hybridDomain, StringComparison.InvariantCultureIgnoreCase)))
                         {
                             this.addOnPremisesFedDomains.Add(hybridDomain);
                         }
                     }
                 }
             }
             if (!TaskCommon.AreEqual(federatedOrganizationIdentifier.DefaultDomain, this.AutoDiscoverHybridDomain))
             {
                 this.updateOnPremisesFedOrgId = true;
             }
         }
         if (this.updateOnPremisesFedOrgId)
         {
             foreach (string text in from d in this.HybridDomains
                      select d.Domain)
             {
                 if (!text.Equals(this.accountNamespace, StringComparison.InvariantCultureIgnoreCase))
                 {
                     this.addOnPremisesFedDomains.Add(text);
                 }
             }
         }
         IFederatedOrganizationIdentifier federatedOrganizationIdentifier2 = base.TenantSession.GetFederatedOrganizationIdentifier();
         string text2 = (federatedOrganizationIdentifier2 != null && federatedOrganizationIdentifier2.DefaultDomain != null) ? federatedOrganizationIdentifier2.DefaultDomain.ToString() : null;
         if (text2 == null || !text2.Equals(this.TenantCoexistenceDomain, StringComparison.InvariantCultureIgnoreCase))
         {
             this.updateTenantFedOrgId = true;
         }
     }
     return(true);
 }
コード例 #13
0
ファイル: TaskCommon.cs プロジェクト: YHZX2013/exchange_diff
 public static string GetDomainFromSubject(SmtpX509Identifier certificateIdentity)
 {
     return(TaskCommon.GetDomainFromSubject(certificateIdentity.CertificateSubject));
 }
コード例 #14
0
        public override bool Configure(ITaskContext taskContext)
        {
            if (!base.Configure(taskContext))
            {
                return(false);
            }
            HybridConfiguration hybridConfigurationObject = taskContext.HybridConfigurationObject;
            SessionParameters   sessionParameters         = new SessionParameters();
            SessionParameters   sessionParameters2        = new SessionParameters();

            if (hybridConfigurationObject.MoveMailboxEnabled != this.onPremOrgRel.MailboxMoveEnabled)
            {
                sessionParameters.Set("MailboxMoveEnabled", hybridConfigurationObject.MoveMailboxEnabled);
            }
            if (hybridConfigurationObject.FreeBusySharingEnabled != this.onPremOrgRel.FreeBusyAccessEnabled || hybridConfigurationObject.FreeBusySharingEnabled != this.tenantOrgRel.FreeBusyAccessEnabled)
            {
                sessionParameters.Set("FreeBusyAccessEnabled", hybridConfigurationObject.FreeBusySharingEnabled);
                sessionParameters2.Set("FreeBusyAccessEnabled", hybridConfigurationObject.FreeBusySharingEnabled);
            }
            if (hybridConfigurationObject.FreeBusySharingEnabled && (this.onPremOrgRel.FreeBusyAccessLevel != FreeBusyAccessLevel.LimitedDetails || this.tenantOrgRel.FreeBusyAccessLevel != FreeBusyAccessLevel.LimitedDetails))
            {
                sessionParameters.Set("FreeBusyAccessLevel", FreeBusyAccessLevel.LimitedDetails);
                sessionParameters2.Set("FreeBusyAccessLevel", FreeBusyAccessLevel.LimitedDetails);
            }
            if (hybridConfigurationObject.OnlineArchiveEnabled != this.onPremOrgRel.ArchiveAccessEnabled)
            {
                sessionParameters.Set("ArchiveAccessEnabled", hybridConfigurationObject.OnlineArchiveEnabled);
            }
            if (hybridConfigurationObject.MailtipsEnabled != this.onPremOrgRel.MailTipsAccessEnabled || hybridConfigurationObject.MailtipsEnabled != this.tenantOrgRel.MailTipsAccessEnabled)
            {
                sessionParameters.Set("MailTipsAccessEnabled", hybridConfigurationObject.MailtipsEnabled);
                sessionParameters2.Set("MailTipsAccessEnabled", hybridConfigurationObject.MailtipsEnabled);
            }
            if (hybridConfigurationObject.MailtipsEnabled && (this.onPremOrgRel.MailTipsAccessLevel != MailTipsAccessLevel.All || this.tenantOrgRel.MailTipsAccessLevel != MailTipsAccessLevel.All))
            {
                sessionParameters.Set("MailTipsAccessLevel", MailTipsAccessLevel.All);
                sessionParameters2.Set("MailTipsAccessLevel", MailTipsAccessLevel.All);
            }
            if (hybridConfigurationObject.MessageTrackingEnabled != this.onPremOrgRel.DeliveryReportEnabled || hybridConfigurationObject.MessageTrackingEnabled != this.tenantOrgRel.DeliveryReportEnabled)
            {
                sessionParameters.Set("DeliveryReportEnabled", hybridConfigurationObject.MessageTrackingEnabled);
                sessionParameters2.Set("DeliveryReportEnabled", hybridConfigurationObject.MessageTrackingEnabled);
            }
            if (hybridConfigurationObject.PhotosEnabled != this.onPremOrgRel.PhotosEnabled || hybridConfigurationObject.PhotosEnabled != this.tenantOrgRel.PhotosEnabled)
            {
                sessionParameters.Set("PhotosEnabled", hybridConfigurationObject.PhotosEnabled);
                sessionParameters2.Set("PhotosEnabled", hybridConfigurationObject.PhotosEnabled);
            }
            string text = (this.onPremOrgRel.TargetOwaURL != null) ? this.onPremOrgRel.TargetOwaURL.ToString() : string.Empty;

            if (hybridConfigurationObject.OwaRedirectionEnabled || !string.IsNullOrEmpty(text))
            {
                if (hybridConfigurationObject.OwaRedirectionEnabled)
                {
                    IEnumerable <IAcceptedDomain> acceptedDomains = taskContext.Parameters.Get <IEnumerable <IAcceptedDomain> >("_tenantAcceptedDomains");
                    if (!string.IsNullOrEmpty(text))
                    {
                        if (!this.ValidateOwaUri(text, acceptedDomains))
                        {
                            sessionParameters.Set("TargetOwaURL", this.GetDefaultOwaUri(acceptedDomains, this.fedOrgId));
                        }
                    }
                    else
                    {
                        sessionParameters.Set("TargetOwaURL", this.GetDefaultOwaUri(acceptedDomains, this.fedOrgId));
                    }
                }
                else
                {
                    sessionParameters.SetNull <string>("TargetOwaURL");
                }
            }
            if (sessionParameters.Count > 0)
            {
                OrganizationRelationship organizationRelationship = taskContext.Parameters.Get <OrganizationRelationship>("_onPremOrgRel");
                base.OnPremisesSession.SetOrganizationRelationship(organizationRelationship.Identity, sessionParameters);
                List <string> list = new List <string>();
                string        item = taskContext.Parameters.Get <string>("_hybridDomain");
                list.Add(item);
                this.onPremOrgRel = TaskCommon.GetOrganizationRelationship(taskContext.OnPremisesSession, TaskCommon.GetOnPremOrgRelationshipName(this.OnPremOrgConfig), list);
                taskContext.Parameters.Set <OrganizationRelationship>("_onPremOrgRel", this.onPremOrgRel);
            }
            if (sessionParameters2.Count > 0)
            {
                OrganizationRelationship organizationRelationship2 = taskContext.Parameters.Get <OrganizationRelationship>("_tenantOrgRel");
                base.TenantSession.SetOrganizationRelationship(organizationRelationship2.Identity, sessionParameters2);
                IEnumerable <string> domains = taskContext.Parameters.Get <IEnumerable <string> >("_hybridDomainList");
                this.tenantOrgRel = TaskCommon.GetOrganizationRelationship(taskContext.TenantSession, TaskCommon.GetTenantOrgRelationshipName(this.OnPremOrgConfig), domains);
                taskContext.Parameters.Set <OrganizationRelationship>("_onPremOrgRel", this.tenantOrgRel);
            }
            this.ConfigureAvailabilityAddressSpace(taskContext);
            return(true);
        }
コード例 #15
0
        public override bool CheckPrereqs(ITaskContext taskContext)
        {
            if (!base.CheckPrereqs(taskContext))
            {
                return(false);
            }
            if (taskContext.HybridConfigurationObject.ExchangeVersion.ExchangeBuild.Major != taskContext.HybridConfigurationObject.MaximumSupportedExchangeObjectVersion.ExchangeBuild.Major)
            {
                base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, HybridStrings.ErrorHybridMustBeUpgraded));
                base.AddLocalizedStringError(HybridStrings.ErrorHybridMustBeUpgraded);
                return(false);
            }
            if (Configuration.RequiresIntraOrganizationConnector(taskContext.HybridConfigurationObject.ServiceInstance) && Configuration.RestrictIOCToSP1OrGreater(taskContext.HybridConfigurationObject.ServiceInstance) && !(taskContext.OnPremisesSession.GetIntraOrganizationConfiguration().DeploymentIsCompleteIOCReady ?? false))
            {
                base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, HybridStrings.ErrorIncompatibleServersDetected));
                base.AddLocalizedStringError(HybridStrings.ErrorIncompatibleServersDetected);
                return(false);
            }
            if (taskContext.HybridConfigurationObject.Domains == null || taskContext.HybridConfigurationObject.Domains.Count == 0)
            {
                base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, HybridStrings.ErrorNoHybridDomains));
                base.AddLocalizedStringError(HybridStrings.ErrorNoHybridDomains);
                return(false);
            }
            IOrderedEnumerable <string> orderedEnumerable = from d in taskContext.HybridConfigurationObject.Domains
                                                            select d.Domain into d
                                                            orderby d
                                                            select d;

            taskContext.Parameters.Set <IEnumerable <string> >("_hybridDomainList", orderedEnumerable);
            IEnumerable <IAcceptedDomain> acceptedDomain = base.TenantSession.GetAcceptedDomain();

            if (acceptedDomain.Count <IAcceptedDomain>() == 0)
            {
                base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, HybridStrings.ErrorNoTenantAcceptedDomains));
                base.AddLocalizedStringError(HybridStrings.ErrorNoTenantAcceptedDomains);
                return(false);
            }
            taskContext.Parameters.Set <IEnumerable <IAcceptedDomain> >("_tenantAcceptedDomains", acceptedDomain);
            string text = null;

            foreach (IAcceptedDomain acceptedDomain2 in acceptedDomain)
            {
                if (acceptedDomain2.IsCoexistenceDomain)
                {
                    text = acceptedDomain2.DomainNameDomain;
                    break;
                }
            }
            if (string.IsNullOrEmpty(text))
            {
                base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, HybridStrings.ErrorNoHybridDomain));
                base.AddLocalizedStringError(HybridStrings.ErrorNoHybridDomain);
                return(false);
            }
            taskContext.Parameters.Set <string>("_hybridDomain", text);
            IEnumerable <IAcceptedDomain> acceptedDomain3 = base.OnPremisesSession.GetAcceptedDomain();

            if (acceptedDomain3.Count <IAcceptedDomain>() == 0)
            {
                base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, HybridStrings.ErrorNoOnPremAcceptedDomains));
                base.AddLocalizedStringError(HybridStrings.ErrorNoOnPremAcceptedDomains);
                return(false);
            }
            taskContext.Parameters.Set <IEnumerable <IAcceptedDomain> >("_onPremAcceptedDomains", acceptedDomain3);
            foreach (string domain in orderedEnumerable)
            {
                if (!GlobalPrereqTask.IsAcceptedDomain(domain, acceptedDomain))
                {
                    base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, HybridStrings.ErrorHybridDomainNotAcceptedOnTenant(domain)));
                    base.AddLocalizedStringError(HybridStrings.ErrorHybridDomainNotAcceptedOnTenant(domain));
                    return(false);
                }
                if (!GlobalPrereqTask.IsAcceptedDomain(domain, acceptedDomain3))
                {
                    base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, HybridStrings.ErrorHybridDomainNotAcceptedOnPrem(domain)));
                    base.AddLocalizedStringError(HybridStrings.ErrorHybridDomainNotAcceptedOnPrem(domain));
                    return(false);
                }
            }
            if (!GlobalPrereqTask.IsAcceptedDomain(text, acceptedDomain))
            {
                base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, HybridStrings.ErrorCoexistenceDomainNotAcceptedOnTenant(text)));
                base.AddLocalizedStringError(HybridStrings.ErrorCoexistenceDomainNotAcceptedOnTenant(text));
                return(false);
            }
            IOrganizationConfig organizationConfig = base.OnPremisesSession.GetOrganizationConfig();
            List <string>       list = new List <string>();

            list.Add(text);
            OrganizationRelationship organizationRelationship = TaskCommon.GetOrganizationRelationship(taskContext.OnPremisesSession, TaskCommon.GetOnPremOrgRelationshipName(organizationConfig), list);

            taskContext.Parameters.Set <OrganizationRelationship>("_onPremOrgRel", organizationRelationship);
            organizationRelationship = TaskCommon.GetOrganizationRelationship(taskContext.TenantSession, TaskCommon.GetTenantOrgRelationshipName(organizationConfig), orderedEnumerable);
            taskContext.Parameters.Set <OrganizationRelationship>("_tenantOrgRel", organizationRelationship);
            foreach (ADObjectId adobjectId in taskContext.HybridConfigurationObject.ClientAccessServers)
            {
                IExchangeServer exchangeServer = base.OnPremisesSession.GetExchangeServer(adobjectId.Name);
                if (!this.HasCASRole(exchangeServer))
                {
                    base.Logger.LogInformation(HybridStrings.HybridInfoTaskLogTemplate(base.Name, HybridStrings.ErrorCASRoleInvalid(exchangeServer.Name)));
                    base.AddLocalizedStringError(HybridStrings.ErrorCASRoleInvalid(exchangeServer.Name));
                    return(false);
                }
            }
            return(true);
        }