Ejemplo n.º 1
0
        private static ADUser GetOrganizationMailbox(IRecipientSession recipientSession, OrganizationCapability capability, string anchorMailboxKey)
        {
            if (recipientSession == null)
            {
                throw new ArgumentNullException("recipientSession");
            }
            List <ADUser> organizationMailboxesByCapability = OrganizationMailbox.GetOrganizationMailboxesByCapability(recipientSession, capability);

            if (organizationMailboxesByCapability == null || organizationMailboxesByCapability.Count == 0)
            {
                ExTraceGlobals.CafeTracer.TraceError <OrganizationCapability, OrganizationId>(0L, "[HttpProxyBackEndHelper.GetOrganizationMailbox] Unable to find organization mailbox with capability {0} for organization {1}.", capability, recipientSession.SessionSettings.CurrentOrganizationId);
                return(null);
            }
            ADUser aduser;

            if (!string.IsNullOrEmpty(anchorMailboxKey) && organizationMailboxesByCapability.Count > 1)
            {
                aduser = organizationMailboxesByCapability[HttpProxyBackEndHelper.ComputeIndex(anchorMailboxKey, organizationMailboxesByCapability.Count)];
            }
            else
            {
                aduser = organizationMailboxesByCapability[0];
            }
            ExTraceGlobals.CafeTracer.TraceDebug <ObjectId, OrganizationCapability, OrganizationId>(0L, "[HttpProxyBackEndHelper.GetOrganizationMailbox] Find organization mailbox {0} with capability {1} for organization {2}.", aduser.Identity, capability, recipientSession.SessionSettings.CurrentOrganizationId);
            return(aduser);
        }
Ejemplo n.º 2
0
        internal static ADUser GetDefaultOrganizationMailbox(IRecipientSession recipientSession, string anchorMailboxKey = null)
        {
            if (recipientSession == null)
            {
                throw new ArgumentNullException("recipientSession");
            }
            ADUser aduser = HttpProxyBackEndHelper.GetOrganizationMailbox(recipientSession, HttpProxyBackEndHelper.DefaultOrganizationCapability, anchorMailboxKey);

            if (aduser == null)
            {
                ADUser[] array = recipientSession.FindADUser(null, QueryScope.SubTree, HttpProxyBackEndHelper.E15OrganizationMailboxFilter, null, 1);
                if (array.Length == 0)
                {
                    ExTraceGlobals.CafeTracer.TraceError <OrganizationId>(0L, "[HttpProxyBackEndHelper.GetDefaultOrganizationMailbox] Unable to find E15 organization mailbox by name for organization {0}.", recipientSession.SessionSettings.CurrentOrganizationId);
                    array = recipientSession.FindADUser(null, QueryScope.SubTree, HttpProxyBackEndHelper.E14EDiscoveryMailboxFilter, null, 1);
                    if (array.Length == 0)
                    {
                        ExTraceGlobals.CafeTracer.TraceError <OrganizationId>(0L, "[HttpProxyBackEndHelper.GetDefaultOrganizationMailbox] Unable to find E14 eDiscovery mailbox by name for organization {0}.", recipientSession.SessionSettings.CurrentOrganizationId);
                    }
                    else
                    {
                        aduser = array[HttpProxyBackEndHelper.ComputeIndex(anchorMailboxKey, array.Length)];
                        ExTraceGlobals.CafeTracer.TraceDebug <ObjectId, OrganizationId>(0L, "[HttpProxyBackEndHelper.GetDefaultOrganizationMailbox] Found E14 eDiscovery mailbox {0} by name for organization {1}.", aduser.Identity, recipientSession.SessionSettings.CurrentOrganizationId);
                    }
                }
                else
                {
                    aduser = array[HttpProxyBackEndHelper.ComputeIndex(anchorMailboxKey, array.Length)];
                    ExTraceGlobals.CafeTracer.TraceDebug <ObjectId, OrganizationId>(0L, "[HttpProxyBackEndHelper.GetDefaultOrganizationMailbox] Found E15 eDiscovery mailbox {0} by name for organization {1}.", aduser.Identity, recipientSession.SessionSettings.CurrentOrganizationId);
                }
            }
            return(aduser);
        }
Ejemplo n.º 3
0
 internal static BackEndServer GetDeterministicBackEndServer <ServiceType>(BackEndServer mailboxServer, string identifier, ClientAccessType clientAccessType) where ServiceType : HttpService
 {
     if (mailboxServer == null)
     {
         throw new ArgumentNullException("mailboxServer");
     }
     if (string.IsNullOrEmpty(identifier))
     {
         throw new ArgumentNullException("identifier");
     }
     if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Cafe.ServersCache.Enabled)
     {
         MiniServer deterministicBackEndServerFromSameSite = ServersCache.GetDeterministicBackEndServerFromSameSite(mailboxServer.Fqdn, Server.E15MinVersion, identifier, false);
         return(new BackEndServer(deterministicBackEndServerFromSameSite.Fqdn, deterministicBackEndServerFromSameSite.VersionNumber));
     }
     HttpProxyBackEndHelper.TopologyWithSites completeServiceTopologyWithSites = HttpProxyBackEndHelper.GetCompleteServiceTopologyWithSites(mailboxServer.Fqdn);
     HttpService[] array = (HttpService[])HttpProxyBackEndHelper.FindAcceptableBackEndService <ServiceType>(completeServiceTopologyWithSites, clientAccessType, (int x) => x >= Server.E15MinVersion);
     if (array.Length > 0)
     {
         int num = HttpProxyBackEndHelper.ComputeIndex(identifier, array.Length);
         ExTraceGlobals.CafeTracer.TraceDebug <int, string, int>(0L, "[HttpProxyBackEndHelper.GetDeterministicBackEndServer] Buckets: {0} Identifier: {1} Index: {2}", array.Length, identifier, num);
         return(new BackEndServer(array[num].ServerFullyQualifiedDomainName, array[num].ServerVersionNumber));
     }
     throw new ServerNotFoundException("Unable to find proper HTTP service.");
 }
        // Token: 0x06000779 RID: 1913 RVA: 0x0001D180 File Offset: 0x0001B380
        public IAsyncResult BeginGetBackEndServerList(MiniRecipient miniRecipient, int maxServers, AsyncCallback callback, object state)
        {
            if (miniRecipient == null)
            {
                throw new ArgumentNullException("miniRecipient");
            }
            if (maxServers <= 0)
            {
                throw new ArgumentException("maxServers needs to be greater than zero");
            }
            this.database   = miniRecipient.Database;
            this.maxServers = maxServers;
            OrganizationId organizationId     = miniRecipient.OrganizationId;
            SmtpAddress    primarySmtpAddress = miniRecipient.PrimarySmtpAddress;

            if (this.database == null)
            {
                ADUser defaultOrganizationMailbox = HttpProxyBackEndHelper.GetDefaultOrganizationMailbox(organizationId, null);
                if (defaultOrganizationMailbox == null || defaultOrganizationMailbox.Database == null)
                {
                    ExTraceGlobals.CafeTracer.TraceError <OrganizationId>(0L, "[BackEndLocator.BeginGetBackEndServerList] Cannot find organization mailbox for organization {1}", organizationId);
                    throw new AdUserNotFoundException(ServerStrings.ADUserNotFound);
                }
                this.database      = defaultOrganizationMailbox.Database;
                primarySmtpAddress = defaultOrganizationMailbox.PrimarySmtpAddress;
            }
            string domainName = null;

            if (organizationId != null && !organizationId.Equals(OrganizationId.ForestWideOrgId))
            {
                domainName = primarySmtpAddress.Domain;
            }
            this.serverLocator = MailboxServerLocator.Create(this.database.ObjectGuid, domainName, this.database.PartitionFQDN);
            bool         flag = true;
            IAsyncResult result;

            try
            {
                result = this.serverLocator.BeginGetServer(callback, state);
                flag   = false;
            }
            catch (Exception ex)
            {
                ExTraceGlobals.CafeTracer.TraceError <Exception>(0L, "[AsyncBackEndLocator.BeginGetBackEndServerList] Caught exception {0}.", ex);
                if (BackEndLocator.ShouldWrapInBackendLocatorException(ex))
                {
                    throw new BackEndLocatorException(ex);
                }
                throw;
            }
            finally
            {
                if (flag)
                {
                    this.serverLocator.Dispose();
                    this.serverLocator = null;
                }
            }
            return(result);
        }
Ejemplo n.º 5
0
        internal static int ComputeIndex(string identifier, int arrayLength)
        {
            int hashCode = HttpProxyBackEndHelper.GetHashCode(identifier);
            int num      = hashCode % arrayLength;

            ExTraceGlobals.CafeTracer.TraceDebug <string, int, int>(0L, "[HttpProxyBackEndHelper.ComputeIndex] AnchorMailboxKey: {0}, HashPivot {1}, Index {2}.", identifier ?? string.Empty, hashCode, num);
            return(num);
        }
Ejemplo n.º 6
0
 private static Uri GetBackEndHttpServiceUrl <ServiceType>(BackEndServer backEndServer) where ServiceType : HttpService
 {
     if (backEndServer == null)
     {
         throw new ArgumentNullException("backEndServer");
     }
     return(BackEndLocator.CallWithExceptionHandling <Uri>(() => HttpProxyBackEndHelper.GetBackEndServiceUrlByServer <ServiceType>(backEndServer)));
 }
Ejemplo n.º 7
0
 internal static BackEndServer GetAnyBackEndServer(bool useServersCache)
 {
     if (useServersCache)
     {
         MiniServer anyBackEndServerWithMinVersion = ServersCache.GetAnyBackEndServerWithMinVersion(Server.E15MinVersion);
         return(new BackEndServer(anyBackEndServerWithMinVersion.Fqdn, anyBackEndServerWithMinVersion.VersionNumber));
     }
     return(HttpProxyBackEndHelper.GetAnyBackEndServerForVersion <WebServicesService>(new ServerVersion(Server.E15MinVersion), false, ClientAccessType.InternalNLBBypass, false));
 }
Ejemplo n.º 8
0
        internal static ADUser GetDefaultOrganizationMailbox(OrganizationId organizationId, string anchorMailboxKey = null)
        {
            if (organizationId == null)
            {
                organizationId = OrganizationId.ForestWideOrgId;
            }
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId), 126, "GetDefaultOrganizationMailbox", "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs");

            return(HttpProxyBackEndHelper.GetDefaultOrganizationMailbox(tenantOrRootOrgRecipientSession, anchorMailboxKey));
        }
Ejemplo n.º 9
0
        private static BackEndServer GetBackEndServerByOrganization(OrganizationId organizationId)
        {
            ADUser defaultOrganizationMailbox = HttpProxyBackEndHelper.GetDefaultOrganizationMailbox(organizationId, null);

            if (defaultOrganizationMailbox == null || defaultOrganizationMailbox.Database == null)
            {
                ExTraceGlobals.CafeTracer.TraceError <OrganizationId>(0L, "[BackEndLocator.GetBackEndServerByOrganization] Cannot find organization mailbox for organization {1}", organizationId);
                throw new AdUserNotFoundException(ServerStrings.ADUserNotFound);
            }
            return(BackEndLocator.GetBackEndServerByDatabase(defaultOrganizationMailbox.Database, organizationId, defaultOrganizationMailbox.PrimarySmtpAddress));
        }
Ejemplo n.º 10
0
 private static Uri GetBackEndHttpServiceUrl <ServiceType>(IMailboxInfo mailbox) where ServiceType : HttpService
 {
     if (mailbox == null)
     {
         throw new ArgumentNullException("mailbox");
     }
     return(BackEndLocator.CallWithExceptionHandling <Uri>(delegate
     {
         BackEndServer backEndServer = BackEndLocator.GetBackEndServer(mailbox);
         return HttpProxyBackEndHelper.GetBackEndServiceUrlByServer <ServiceType>(backEndServer);
     }));
 }
Ejemplo n.º 11
0
        internal static Uri GetE12ExternalUrl <ServiceType>(BackEndServer mailboxServer) where ServiceType : HttpService
        {
            if (mailboxServer == null)
            {
                throw new ArgumentNullException("mailboxServer");
            }
            if (mailboxServer.Version >= Server.E14MinVersion)
            {
                throw new ArgumentException("Mailbox server version is higher then E12", "mailboxServer");
            }
            HttpProxyBackEndHelper.TopologyWithSites legacyServiceTopologyWithSites = HttpProxyBackEndHelper.GetLegacyServiceTopologyWithSites(mailboxServer.Fqdn);
            HttpService httpService = HttpProxyBackEndHelper.GetBestBackEndServiceForVersion <ServiceType>(legacyServiceTopologyWithSites, ClientAccessType.External, (int x) => x >= Server.E2007MinVersion && x < Server.E14MinVersion);

            return(httpService.Url);
        }
Ejemplo n.º 12
0
        internal static Uri GetBackEndServiceUrlByServer <ServiceType>(BackEndServer backEndServer) where ServiceType : HttpService
        {
            if (backEndServer.IsE15OrHigher)
            {
                return(GlobalServiceUrls.GetInternalUrl <ServiceType>(backEndServer.Fqdn));
            }
            HttpProxyBackEndHelper.TopologyWithSites legacyServiceTopologyWithSites = HttpProxyBackEndHelper.GetLegacyServiceTopologyWithSites(backEndServer.Fqdn);
            ServiceType serviceType = legacyServiceTopologyWithSites.ServiceTopology.FindAny <ServiceType>(ClientAccessType.InternalNLBBypass, (ServiceType service) => service != null && !service.IsFrontEnd && service.ServerFullyQualifiedDomainName.Equals(backEndServer.Fqdn, StringComparison.OrdinalIgnoreCase), "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetBackEndServiceUrlByServer", 568);

            if (serviceType != null)
            {
                ExTraceGlobals.CafeTracer.TraceDebug <BackEndServer>(0L, "[HttpProxyBackEndHelper.GetBackEndServiceUrlByServer] Found HTTP service on the specified back end server {0}.", backEndServer);
                return(serviceType.Url);
            }
            serviceType = HttpProxyBackEndHelper.GetBestBackEndServiceForVersion <ServiceType>(legacyServiceTopologyWithSites, ClientAccessType.InternalNLBBypass, (int x) => new ServerVersion(x).Major == new ServerVersion(backEndServer.Version).Major);
            ExTraceGlobals.CafeTracer.TraceDebug <string, int>(0L, "[HttpProxyBackEndHelper.GetBackEndServiceByServer] Found HTTP service {0} with version {1}.", serviceType.ServerFullyQualifiedDomainName, serviceType.ServerVersionNumber);
            if (serviceType != null)
            {
                return(serviceType.Url);
            }
            throw new ServerNotFoundException("Unable to find proper HTTP service.");
        }
Ejemplo n.º 13
0
        private static HttpProxyBackEndHelper.TopologyWithSites GetCompleteServiceTopologyWithSites(string serverFqdn)
        {
            ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetCompleteServiceTopologyWithSites", 1040);

            return(HttpProxyBackEndHelper.GetServiceTopologyWithSites(serverFqdn, currentServiceTopology));
        }
Ejemplo n.º 14
0
 internal static BackEndServer GetAnyBackEndServer()
 {
     return(HttpProxyBackEndHelper.GetAnyBackEndServer(VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Cafe.ServersCache.Enabled));
 }
Ejemplo n.º 15
0
 public static BackEndServer GetAnyBackEndServer()
 {
     return(BackEndLocator.CallWithExceptionHandling <BackEndServer>(() => HttpProxyBackEndHelper.GetAnyBackEndServer()));
 }