public IExchangeCertificate GetExchangeCertificate(string server, SmtpX509Identifier certificateName) { foreach (IExchangeCertificate exchangeCertificate in this.GetExchangeCertificate(server)) { if (TaskCommon.AreEqual(exchangeCertificate.Identifier, certificateName)) { return(exchangeCertificate); } } return(null); }
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); }
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); }