private string GetE15MultitenancyOwaServiceUrl(IExchangePrincipal exchangePrincipal)
        {
            Uri       uri = null;
            Exception ex  = null;

            try
            {
                uri = FrontEndLocator.GetFrontEndOwaUrl(exchangePrincipal);
            }
            catch (ServerNotFoundException ex2)
            {
                ex = ex2;
            }
            catch (ADTransientException ex3)
            {
                ex = ex3;
            }
            catch (DataSourceOperationException ex4)
            {
                ex = ex4;
            }
            catch (DataValidationException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex != null)
                {
                    throw new NoExternalOwaAvailableException(ex);
                }
            }
            return(uri.ToString());
        }
Beispiel #2
0
 private void PopulateProtocolSettings(CASMailbox mailbox)
 {
     this.AddConnectionSettingDetails(mailbox, ServiceType.Pop3, true, FrontEndLocator.GetFrontEndPop3SettingsForLocalServer());
     this.AddConnectionSettingDetails(mailbox, ServiceType.Imap4, true, FrontEndLocator.GetFrontEndImap4SettingsForLocalServer());
     this.AddConnectionSettingDetails(mailbox, ServiceType.Smtp, true, FrontEndLocator.GetFrontEndSmtpSettingsForLocalServer());
     this.AddConnectionSettingDetails(mailbox, ServiceType.Pop3, false, FrontEndLocator.GetInternalPop3SettingsForLocalServer());
     this.AddConnectionSettingDetails(mailbox, ServiceType.Imap4, false, FrontEndLocator.GetInternalImap4SettingsForLocalServer());
     this.AddConnectionSettingDetails(mailbox, ServiceType.Smtp, false, FrontEndLocator.GetInternalSmtpSettingsForLocalServer());
 }
Beispiel #3
0
        private Uri GetEcpUrl(ExchangePrincipal mailbox)
        {
            Uri       uri = null;
            Exception ex  = null;

            try
            {
                if (mailbox.MailboxInfo.Location.ServerVersion >= Server.E15MinVersion && GlobalSettings.IsMultiTenancyEnabled)
                {
                    uri = FrontEndLocator.GetFrontEndEcpUrl(mailbox);
                    AirSyncDiagnostics.TraceDebug <ExchangePrincipal, Uri>(ExTraceGlobals.RequestsTracer, null, "ABQMail:ECP URL for user {0} - {1} (E15 Multitenancy)", mailbox, uri);
                }
                else
                {
                    ServiceTopology    serviceTopology = GlobalSettings.IsMultiTenancyEnabled ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ABQMailHelper.cs", "GetEcpUrl", 605) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ABQMailHelper.cs", "GetEcpUrl", 605);
                    ServerVersion      serverVersion   = new ServerVersion(mailbox.MailboxInfo.Location.ServerVersion);
                    int                majorversion    = serverVersion.Major;
                    IList <EcpService> list            = serviceTopology.FindAll <EcpService>(mailbox, ClientAccessType.External, (EcpService service) => new ServerVersion(service.ServerVersionNumber).Major == majorversion, "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ABQMailHelper.cs", "GetEcpUrl", 610);
                    foreach (EcpService ecpService in list)
                    {
                        if (ecpService != null && ecpService.Url != null)
                        {
                            uri = ecpService.Url;
                            AirSyncDiagnostics.TraceDebug <ExchangePrincipal, Uri>(ExTraceGlobals.RequestsTracer, null, "ABQMail:ECP URL for user {0} - {1} (not E15 Multitenancy)", mailbox, uri);
                            break;
                        }
                    }
                }
            }
            catch (ServerNotFoundException ex2)
            {
                ex = ex2;
            }
            catch (ADTransientException ex3)
            {
                ex = ex3;
            }
            catch (DataSourceOperationException ex4)
            {
                ex = ex4;
            }
            catch (DataValidationException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex != null)
                {
                    AirSyncDiagnostics.TraceError <ExchangePrincipal, Exception>(ExTraceGlobals.RequestsTracer, null, "ABQMail:Could not retrieve ECP URL for user {0} - {1}", mailbox, ex);
                }
            }
            return(uri);
        }
        private static Uri GetE15MultitenancyEcpServiceUrl(ExchangePrincipal exchangePrincipal, ClientAccessType type)
        {
            ExTraceGlobals.ApplicationlogicTracer.TraceDebug(0L, "Entering GetE15MultitenancyEcpServiceUrl");
            Uri       uri = null;
            Exception ex  = null;

            try
            {
                switch (type)
                {
                case ClientAccessType.Internal:
                    uri = BackEndLocator.GetBackEndEcpUrl(exchangePrincipal.MailboxInfo);
                    break;

                case ClientAccessType.External:
                    uri = FrontEndLocator.GetFrontEndEcpUrl(exchangePrincipal);
                    break;

                default:
                    ExAssert.RetailAssert(false, "Invalid client access type {0}", new object[]
                    {
                        type
                    });
                    break;
                }
                ExTraceGlobals.ApplicationlogicTracer.TraceDebug <Uri>(0L, "ecpUri='{0}'", uri);
            }
            catch (ServerNotFoundException ex2)
            {
                ex = ex2;
            }
            catch (ADTransientException ex3)
            {
                ex = ex3;
            }
            catch (DataSourceOperationException ex4)
            {
                ex = ex4;
            }
            catch (DataValidationException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex != null)
                {
                    ExTraceGlobals.ApplicationlogicTracer.TraceError <Exception>(0L, "GetE15MultitenancyEcpServiceUrl throwing an exception: {0}", ex);
                }
            }
            return(uri);
        }
Beispiel #5
0
 private static string GetEwsUrl(IExchangePrincipal exchangePrincipal, bool failOnError)
 {
     try
     {
         Uri frontEndWebServicesUrl = FrontEndLocator.GetFrontEndWebServicesUrl(exchangePrincipal);
         return(frontEndWebServicesUrl.ToString());
     }
     catch (LocalizedException ex)
     {
         MailboxUrls.Tracer.TraceWarning <string>(0L, "Not able to get the ews url by FrontEndLocator. Exception: {0}", ex.ToString());
         if (failOnError)
         {
             throw;
         }
     }
     return(null);
 }
Beispiel #6
0
        private Uri GetECPExternalUrl()
        {
            Uri           result        = null;
            RbacPrincipal rbacPrincipal = RbacPrincipal.Current;

            if (rbacPrincipal.IsInRole("Mailbox"))
            {
                ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromDirectoryObjectId((IRecipientSession)((RecipientObjectResolver)RecipientObjectResolver.Instance).CreateAdSession(), rbacPrincipal.ExecutingUserId, RemotingOptions.LocalConnectionsOnly);
                try
                {
                    result = FrontEndLocator.GetFrontEndEcpUrl(exchangePrincipal);
                }
                catch (ServerNotFoundException)
                {
                }
            }
            return(result);
        }
Beispiel #7
0
        public static Uri GetOwaBaseLink(Action errorHandler, ExchangePrincipal targetPrincipal, bool supportsIntegratedAuth)
        {
            Uri uri = null;

            if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled)
            {
                uri = FrontEndLocator.GetFrontEndOwaUrl(targetPrincipal);
                if (uri == null)
                {
                    Factory.Current.EventLog.LogEvent(InfoWorkerEventLogConstants.Tuple_DiscoveryFailedToGetOWAUrl, null, new object[]
                    {
                        targetPrincipal.MailboxInfo.Location.ServerFqdn,
                        targetPrincipal.MailboxInfo.OrganizationId.OrganizationalUnit.ObjectGuid,
                        targetPrincipal.MailboxInfo.MailboxGuid
                    });
                }
                else if (!string.IsNullOrEmpty(targetPrincipal.MailboxInfo.PrimarySmtpAddress.ToString()))
                {
                    SmtpAddress primarySmtpAddress = targetPrincipal.MailboxInfo.PrimarySmtpAddress;
                    if (!string.IsNullOrEmpty(primarySmtpAddress.Domain))
                    {
                        uri = LinkUtils.AppendRelativePath(uri, primarySmtpAddress.Domain, true);
                    }
                }
            }
            else
            {
                OwaService owaService = LinkUtils.GetOwaService(targetPrincipal);
                if (owaService != null)
                {
                    uri = owaService.Url;
                    if (supportsIntegratedAuth && owaService.IntegratedFeaturesEnabled)
                    {
                        uri = LinkUtils.AppendRelativePath(uri, "integrated", true);
                    }
                }
                else if (errorHandler != null)
                {
                    errorHandler();
                }
            }
            return(uri);
        }
Beispiel #8
0
 // Token: 0x06001A13 RID: 6675 RVA: 0x00097268 File Offset: 0x00095468
 private void AddEndpointSettings(ServiceType type, bool isExternal)
 {
     if (type == ServiceType.Pop3)
     {
         ProtocolConnectionSettings frontEndPop3SettingsForLocalServer = FrontEndLocator.GetFrontEndPop3SettingsForLocalServer();
         this.AddConnectionSettingDetails(type, isExternal, frontEndPop3SettingsForLocalServer);
         return;
     }
     if (type == ServiceType.Imap4)
     {
         ProtocolConnectionSettings frontEndImap4SettingsForLocalServer = FrontEndLocator.GetFrontEndImap4SettingsForLocalServer();
         this.AddConnectionSettingDetails(type, isExternal, frontEndImap4SettingsForLocalServer);
         return;
     }
     if (type == ServiceType.Smtp)
     {
         ProtocolConnectionSettings frontEndSmtpSettingsForLocalServer = FrontEndLocator.GetFrontEndSmtpSettingsForLocalServer();
         this.AddConnectionSettingDetails(type, isExternal, frontEndSmtpSettingsForLocalServer);
     }
 }
        private static bool TryFindOwaServiceUrl(IExchangePrincipal exchangePrincipal, out Exception exception)
        {
            exception = null;
            Uri frontEndOwaUrl;

            try
            {
                frontEndOwaUrl = FrontEndLocator.GetFrontEndOwaUrl(exchangePrincipal);
            }
            catch (ServerNotFoundException ex)
            {
                exception = ex;
                return(false);
            }
            DefaultExtensionTable.baseOwaUrl = frontEndOwaUrl.ToString().TrimEnd(new char[]
            {
                '/'
            });
            return(true);
        }
        // Token: 0x06000230 RID: 560 RVA: 0x0000D4F0 File Offset: 0x0000B6F0
        protected override void WriteConfigXml(XmlWriter xmlFragment)
        {
            if (base.RequestedRecipient == null)
            {
                this.WriteErrorResponse(xmlFragment, "2", Strings.MobileSyncAddressNotFound.ToString(), string.Empty, base.RequestData, null, null);
                return;
            }
            if (base.RequestedRecipient.RecipientType != RecipientType.UserMailbox)
            {
                this.WriteErrorResponse(xmlFragment, "9", Strings.MobileSyncBadAddress.ToString(), base.RequestedRecipient.RecipientType.ToString(), base.RequestData, base.RequestedRecipient.DisplayName, base.RequestedRecipient.PrimarySmtpAddress.ToString());
                return;
            }
            ADUser            adUser            = base.RequestedRecipient as ADUser;
            ExchangePrincipal exchangePrincipal = Common.GetExchangePrincipal(adUser);

            if (exchangePrincipal == null)
            {
                this.WriteErrorResponse(xmlFragment, "1", Strings.ActiveDirectoryFailure.ToString(), base.RequestedRecipient.RecipientType.ToString(), base.RequestData, base.RequestedRecipient.DisplayName, base.RequestedRecipient.PrimarySmtpAddress.ToString());
                return;
            }
            string mobileName   = null;
            string certUrl      = null;
            string certTemplate = null;
            bool   certEnabled  = false;
            VariantConfigurationSnapshot configuration = exchangePrincipal.GetConfiguration();

            if (Common.SkipServiceTopologyInDatacenter(configuration))
            {
                Uri datacenterFrontEndEasUrl = FrontEndLocator.GetDatacenterFrontEndEasUrl();
                if (datacenterFrontEndEasUrl != null)
                {
                    mobileName = datacenterFrontEndEasUrl.ToString();
                }
            }
            else
            {
                ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\autodisc\\src\\Providers\\MobileSync\\Web\\MobileSyncProvider.cs", "WriteConfigXml", 376);
                Site            site = currentServiceTopology.GetSite(exchangePrincipal.MailboxInfo.Location.ServerFqdn, "f:\\15.00.1497\\sources\\dev\\autodisc\\src\\Providers\\MobileSync\\Web\\MobileSyncProvider.cs", "WriteConfigXml", 377);
                SiteCostComparer <MobileSyncService> comparer = new SiteCostComparer <MobileSyncService>(currentServiceTopology, site);
                MobileSyncService cheapest        = null;
                MobileSyncService cheapestToProxy = null;
                currentServiceTopology.ForEach <MobileSyncService>(delegate(MobileSyncService service)
                {
                    if (service.ClientAccessType == ClientAccessType.External)
                    {
                        if (service.ServerVersionNumber == exchangePrincipal.MailboxInfo.Location.ServerVersion && (cheapest == null || comparer.Compare(cheapest, service) > 0))
                        {
                            cheapest = service;
                            return;
                        }
                        if (cheapestToProxy == null || comparer.Compare(cheapestToProxy, service) > 0)
                        {
                            if (service.ServerVersionNumber > exchangePrincipal.MailboxInfo.Location.ServerVersion)
                            {
                                cheapestToProxy = service;
                                return;
                            }
                            ServerVersion serverVersion  = new ServerVersion(exchangePrincipal.MailboxInfo.Location.ServerVersion);
                            ServerVersion serverVersion2 = new ServerVersion(service.ServerVersionNumber);
                            if (serverVersion2.Major >= serverVersion.Major && serverVersion2.Minor >= serverVersion.Minor)
                            {
                                cheapestToProxy = service;
                            }
                        }
                    }
                }, "f:\\15.00.1497\\sources\\dev\\autodisc\\src\\Providers\\MobileSync\\Web\\MobileSyncProvider.cs", "WriteConfigXml", 388);
                if (cheapest == null && cheapestToProxy == null)
                {
                    this.WriteErrorResponse(xmlFragment, "1", Strings.ExternalUrlNotFound.ToString(), base.RequestedRecipient.RecipientType.ToString(), base.RequestData, base.RequestedRecipient.DisplayName, base.RequestedRecipient.PrimarySmtpAddress.ToString());
                    return;
                }
                if (cheapest == null || (cheapestToProxy != null && comparer.Compare(cheapest, cheapestToProxy) > 0))
                {
                    cheapest = cheapestToProxy;
                }
                mobileName   = cheapest.Url.ToString();
                certUrl      = cheapest.CertificateAuthorityUrl;
                certTemplate = cheapest.CertEnrollTemplateName;
                certEnabled  = cheapest.IsCertEnrollEnabled;
            }
            Common.StartEnvelope(xmlFragment);
            xmlFragment.WriteStartElement("Response", this.ResponseNs);
            xmlFragment.WriteElementString("Culture", this.ResponseNs, MobileSyncProvider.defaultCulture);
            this.WriteUserFragment(xmlFragment, base.RequestedRecipient.DisplayName, base.RequestedRecipient.PrimarySmtpAddress.ToString());
            xmlFragment.WriteStartElement("Action", this.ResponseNs);
            xmlFragment.WriteStartElement("Settings", this.ResponseNs);
            this.WriteServerFragment(xmlFragment, mobileName, certUrl, certTemplate, certEnabled);
            xmlFragment.WriteEndElement();
            this.WriteMailboxesFragment(xmlFragment, exchangePrincipal);
            xmlFragment.WriteEndElement();
            xmlFragment.WriteEndElement();
            Common.EndEnvelope(xmlFragment);
            Common.EventLog.LogEvent(AutodiscoverEventLogConstants.Tuple_InfoProvConfigurationResponse, Common.PeriodicKey, new object[]
            {
                (base.RequestData.LegacyDN == null) ? base.RequestData.EMailAddress : base.RequestData.LegacyDN
            });
            RequestDetailsLoggerBase <RequestDetailsLogger> .Current.AppendGenericInfo("MobileSyncConfigSuccess", base.RequestData.LegacyDN ?? base.RequestData.EMailAddress);
        }
Beispiel #11
0
 // Token: 0x06000397 RID: 919 RVA: 0x00016598 File Offset: 0x00014798
 private void ExecuteGetDomainSettingsCommand(IPrincipal callingPrincipal, GetDomainSettingsCallContext callContext)
 {
     this.CheckIdentity(callingPrincipal);
     if (callContext.RequestedSettings.Contains(DomainConfigurationSettingName.ExternalEwsUrl) && callContext.Domains != null && callContext.Domains.Count > 0)
     {
         Uri uri;
         int currentExchangeMajorVersion;
         if (Common.SkipServiceTopologyInDatacenter())
         {
             uri = FrontEndLocator.GetDatacenterFrontEndWebServicesUrl();
             currentExchangeMajorVersion = Server.CurrentExchangeMajorVersion;
         }
         else
         {
             uri = GetDomainSettingsRequestMessage.GetRandomCasExternalServiceUri <WebServicesService>(callContext.RequestedVersion, out currentExchangeMajorVersion);
         }
         DomainStringSetting setting  = null;
         DomainStringSetting setting2 = null;
         if (null != uri)
         {
             setting = new DomainStringSetting
             {
                 Name  = GetDomainSettingsRequestMessage.externalEwsUrlSettingName,
                 Value = uri.AbsoluteUri
             };
         }
         bool flag = callContext.RequestedSettings.Contains(DomainConfigurationSettingName.ExternalEwsVersion);
         if (flag)
         {
             ServerVersion serverVersion = new ServerVersion(currentExchangeMajorVersion);
             setting2 = new DomainStringSetting
             {
                 Name  = GetDomainSettingsRequestMessage.externalEwsVersionSettingName,
                 Value = string.Format(CultureInfo.InvariantCulture, "{0:d}.{1:d2}.{2:d4}.{3:d3}", new object[]
                 {
                     serverVersion.Major,
                     serverVersion.Minor,
                     serverVersion.Build,
                     serverVersion.Revision
                 })
             };
         }
         using (IEnumerator <string> enumerator = callContext.Domains.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 string         text           = enumerator.Current;
                 DomainResponse domainResponse = new DomainResponse();
                 domainResponse.ErrorCode           = ErrorCode.NoError;
                 domainResponse.ErrorMessage        = Strings.NoError;
                 domainResponse.DomainSettingErrors = new DomainSettingErrorCollection();
                 domainResponse.DomainSettings      = new DomainSettingCollection();
                 GetDomainSettingsRequestMessage.AddSettingToResponse(domainResponse, setting, GetDomainSettingsRequestMessage.externalEwsUrlSettingName);
                 if (flag)
                 {
                     GetDomainSettingsRequestMessage.AddSettingToResponse(domainResponse, setting2, GetDomainSettingsRequestMessage.externalEwsVersionSettingName);
                 }
                 callContext.Response.DomainResponses.Add(domainResponse);
             }
             return;
         }
     }
     callContext.Response.ErrorCode    = ErrorCode.InvalidRequest;
     callContext.Response.ErrorMessage = Strings.InvalidRequest;
 }