예제 #1
0
 private EcpService(TopologyServerInfo serverInfo, Uri url, ClientAccessType clientAccessType, AuthenticationMethod authenticationMethod, MiniVirtualDirectory virtualDirectory) : base(serverInfo, ServiceType.ExchangeControlPanel, url, clientAccessType, authenticationMethod, virtualDirectory)
 {
     this.LiveIdAuthentication = virtualDirectory.LiveIdAuthentication;
     this.MetabasePath         = virtualDirectory.MetabasePath;
     this.AdminEnabled         = virtualDirectory.AdminEnabled;
     this.OwaOptionsEnabled    = virtualDirectory.OwaOptionsEnabled;
 }
예제 #2
0
 private RpcHttpService(TopologyServerInfo serverInfo, Uri url, ClientAccessType clientAccessType, AuthenticationMethod authenticationMethod, MiniVirtualDirectory virtualDirectory) : base(serverInfo, ServiceType.RpcHttp, url, clientAccessType, authenticationMethod, virtualDirectory)
 {
     this.IISAuthenticationMethods           = Service.ConvertToReadOnlyCollection <AuthenticationMethod>(virtualDirectory.IISAuthenticationMethods);
     this.ExternalClientAuthenticationMethod = virtualDirectory.ExternalClientAuthenticationMethod;
     this.InternalClientAuthenticationMethod = virtualDirectory.InternalClientAuthenticationMethod;
     this.XropUrl = virtualDirectory.XropUrl;
 }
예제 #3
0
 internal Service(TopologyServerInfo serverInfo, ServiceType serviceType, ClientAccessType clientAccessType, AuthenticationMethod authenticationMethod)
 {
     this.ServerInfo           = serverInfo;
     this.ServiceType          = serviceType;
     this.ClientAccessType     = clientAccessType;
     this.AuthenticationMethod = authenticationMethod;
 }
예제 #4
0
 private MobileSyncService(TopologyServerInfo serverInfo, Uri url, ClientAccessType clientAccessType, AuthenticationMethod authenticationMethod, MiniVirtualDirectory virtualDirectory) : base(serverInfo, ServiceType.MobileSync, url, clientAccessType, authenticationMethod, virtualDirectory)
 {
     this.VirtualDirectoryIdentity = virtualDirectory.ToString();
     this.IsCertEnrollEnabled      = virtualDirectory.MobileClientCertificateProvisioningEnabled;
     this.CertificateAuthorityUrl  = virtualDirectory.MobileClientCertificateAuthorityURL;
     this.CertEnrollTemplateName   = virtualDirectory.MobileClientCertTemplateName;
 }
예제 #5
0
        public static string DiscoverEwsUrl(IExchangePrincipal mailbox)
        {
            Uri uri;

            if (!EwsHelper.IsDatacenter)
            {
                EwsHelper.Tracer.TraceDebug(0L, "Not running in DC. Will use ServiceTopology to discover the url");
                ServerVersion mailboxVersion = new ServerVersion(mailbox.MailboxInfo.Location.ServerVersion);
                IList <WebServicesService> list;
                try
                {
                    ClientAccessType clientAccessType = EwsHelper.ClientAccessType;
                    EwsHelper.Tracer.TraceDebug <ClientAccessType>(0L, "Will try to discover the URL for EWS with the following client access type: {0}", clientAccessType);
                    ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Management\\EwsDriver\\EwsHelper.cs", "DiscoverEwsUrl", 119);
                    list = currentServiceTopology.FindAll <WebServicesService>(mailbox, clientAccessType, delegate(WebServicesService service)
                    {
                        ServerVersion serverVersion = new ServerVersion(service.ServerVersionNumber);
                        return(mailboxVersion.Major == serverVersion.Major && mailboxVersion.Minor <= serverVersion.Minor && !service.IsOutOfService);
                    }, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Management\\EwsDriver\\EwsHelper.cs", "DiscoverEwsUrl", 121);
                }
                catch (LocalizedException arg)
                {
                    EwsHelper.Tracer.TraceError <IExchangePrincipal, LocalizedException>(0L, "Unable to discover internal URL for EWS for mailbox {0} due exception {1}", mailbox, arg);
                    return(null);
                }
                if (list.Count == 0)
                {
                    EwsHelper.Tracer.TraceError <IExchangePrincipal>(0L, "Unable to find internal URL for EWS for mailbox {0}", mailbox);
                    return(null);
                }
                WebServicesService webServicesService;
                if ((webServicesService = list.FirstOrDefault((WebServicesService service) => string.Equals(service.ServerFullyQualifiedDomainName, mailbox.MailboxInfo.Location.ServerFqdn, StringComparison.OrdinalIgnoreCase) && service.Url != null)) == null && (webServicesService = list.FirstOrDefault(delegate(WebServicesService service)
                {
                    ServerVersion serverVersion = new ServerVersion(service.ServerVersionNumber);
                    return(service.Url != null && mailboxVersion.Major == serverVersion.Major && mailboxVersion.Minor == serverVersion.Minor);
                })) == null)
                {
                    webServicesService = list.FirstOrDefault((WebServicesService service) => service.Url != null);
                }
                WebServicesService webServicesService2 = webServicesService;
                uri = ((webServicesService2 == null) ? null : webServicesService2.Url);
                goto IL_1EA;
            }
            EwsHelper.Tracer.TraceDebug(0L, "Running in DC. Will use BackEndLocator to discover the url");
            if (EwsHelper.discoveryEwsInternalUrl == null)
            {
                EwsHelper.discoveryEwsInternalUrl = (Func <IMailboxInfo, Uri>)Delegate.CreateDelegate(typeof(Func <IMailboxInfo, Uri>), Type.GetType("Microsoft.Exchange.Data.ApplicationLogic.Cafe.BackEndLocator, Microsoft.Exchange.Data.ApplicationLogic").GetMethod("GetBackEndWebServicesUrl", BindingFlags.Static | BindingFlags.Public, null, new Type[]
                {
                    typeof(IMailboxInfo)
                }, null));
            }
            uri = EwsHelper.discoveryEwsInternalUrl(mailbox.MailboxInfo);
IL_1EA:
            if (!(uri == null))
            {
                return(uri.ToString());
            }
            return(null);
        }
 public ServerVersionAnchorMailbox(ServerVersion serverVersion, ClientAccessType clientAccessType, IRequestContext requestContext) : base(AnchorSource.ServerVersion, serverVersion, requestContext)
 {
     this.ClientAccessType         = clientAccessType;
     base.NotFoundExceptionCreator = delegate()
     {
         string message = string.Format("Cannot find Mailbox server with {0}.", this.ServerVersion);
         return(new ServerNotFoundException(message, this.ServerVersion.ToString()));
     };
 }
예제 #7
0
        public IList <T> FindAll <T>(IExchangePrincipal mailboxUser, ClientAccessType clientAccessType, Predicate <T> serviceFilter, [CallerFilePath] string callerFilePath = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int callerFileLine = 0) where T : Service
        {
            ServiceTopologyLog.Instance.Append(callerFilePath, memberName, callerFileLine);
            if (mailboxUser == null)
            {
                throw new ArgumentNullException("mailboxUser");
            }
            if (serviceFilter == null)
            {
                throw new ArgumentNullException("serviceFilter");
            }
            EnumValidator.ThrowIfInvalid <ClientAccessType>(clientAccessType, "clientAccessType");
            ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug((long)this.GetHashCode(), "ServiceTopology::FindAll<{0}>. Finding services. CurrentFQDN = {1}. UserFQDN = {2}. ClientAccessType = {3}.", new object[]
            {
                typeof(T).ToString(),
                this.localServerInfo.ServerFullyQualifiedDomainName,
                mailboxUser.MailboxInfo.Location.ServerFqdn,
                clientAccessType
            });
            Site mailboxSite = this.GetSite(mailboxUser.MailboxInfo.Location.ServerFqdn, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceTopology.cs", "FindAll", 1488);

            ServiceTopology.ServiceComparer <T> comparer     = new ServiceTopology.ServiceComparer <T>(this, mailboxUser.MailboxInfo.Location.ServerFqdn);
            SortedDictionary <T, List <T> >     serviceLists = new SortedDictionary <T, List <T> >(comparer);
            List <T> list = new List <T>();

            this.ForEach <T>(delegate(T service)
            {
                if (ServiceTopology.IsOnSite(service, mailboxSite, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceTopology.cs", "FindAll", 1496) && service.ClientAccessType == clientAccessType && serviceFilter(service))
                {
                    if (!serviceLists.ContainsKey(service))
                    {
                        serviceLists.Add(service, new List <T>());
                    }
                    int num = ServiceTopology.Random.Next(serviceLists[service].Count + 1);
                    ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug((long)this.GetHashCode(), "ServiceTopology::FindAll<{0}>. Inserting a service into {1} of {2}. FQDN = {3}.", new object[]
                    {
                        typeof(T).ToString(),
                        num,
                        serviceLists[service].Count,
                        service.ServerFullyQualifiedDomainName
                    });
                    serviceLists[service].Insert(num, service);
                }
            }, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceTopology.cs", "FindAll", 1492);
            foreach (KeyValuePair <T, List <T> > keyValuePair in serviceLists)
            {
                list.AddRange(keyValuePair.Value);
            }
            return(list.AsReadOnly());
        }
예제 #8
0
        private static Uri GetEcpServiceUrl(ExchangePrincipal principal, ClientAccessType type)
        {
            bool enabled = VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled;

            if (principal.MailboxInfo.Location.ServerVersion >= Server.E15MinVersion && enabled)
            {
                return(TextMessagingHelper.GetE15MultitenancyEcpServiceUrl(principal, type));
            }
            ServiceTopology serviceTopology = enabled ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\sms\\TextMessagingHelper.cs", "GetEcpServiceUrl", 371) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\sms\\TextMessagingHelper.cs", "GetEcpServiceUrl", 371);

            if (serviceTopology != null)
            {
                IList <EcpService> list = serviceTopology.FindAll <EcpService>(principal, type, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\sms\\TextMessagingHelper.cs", "GetEcpServiceUrl", 374);
                if (list != null && 0 < list.Count)
                {
                    return(list[0].Url);
                }
            }
            return(null);
        }
예제 #9
0
        // Token: 0x06000182 RID: 386 RVA: 0x00008390 File Offset: 0x00006590
        public bool TryGetProtocolUrl(ClientAccessType clientAccessType, MapiHttpProtocolUrls.Protocol mapiHttpProtocol, out Uri protocolUrl)
        {
            Uri uri = (clientAccessType == ClientAccessType.Internal) ? this.InternalBaseUrl : this.ExternalBaseUrl;

            if (uri != null)
            {
                if (mapiHttpProtocol == MapiHttpProtocolUrls.Protocol.Emsmdb)
                {
                    protocolUrl = new Uri(MapiHttpEndpoints.GetMailboxUrl(uri.Host, this.MailboxId));
                    return(true);
                }
                if (mapiHttpProtocol == MapiHttpProtocolUrls.Protocol.Nspi)
                {
                    protocolUrl = new Uri(MapiHttpEndpoints.GetAddressBookUrl(uri.Host, this.MailboxId));
                    return(true);
                }
            }
            protocolUrl = null;
            return(false);
        }
예제 #10
0
        private SmtpService(TopologyServerInfo serverInfo, ClientAccessType clientAccessType, AuthenticationMethod authenticationMethod, MiniReceiveConnector smtpReceiveConnector, Hostname hostname) : base(serverInfo, ServiceType.Smtp, clientAccessType, authenticationMethod)
        {
            bool           flag           = (smtpReceiveConnector.AuthMechanism & (AuthMechanisms.Tls | AuthMechanisms.BasicAuthRequireTLS)) != AuthMechanisms.None;
            EncryptionType?encryptionType = null;

            if (flag)
            {
                encryptionType = new EncryptionType?(EncryptionType.TLS);
            }
            List <ProtocolConnectionSettings> list = new List <ProtocolConnectionSettings>(smtpReceiveConnector.Bindings.Count);
            HashSet <int> hashSet = new HashSet <int>();

            foreach (IPBinding ipbinding in smtpReceiveConnector.Bindings)
            {
                if (!hashSet.Contains(ipbinding.Port))
                {
                    list.Add(new ProtocolConnectionSettings(hostname, ipbinding.Port, encryptionType));
                    hashSet.Add(ipbinding.Port);
                }
            }
            this.ProtocolConnectionSettings = new ReadOnlyCollection <ProtocolConnectionSettings>(list);
        }
예제 #11
0
        public T FindAny <T>(ClientAccessType clientAccessType, Predicate <T> serviceFilter, [CallerFilePath] string callerFilePath = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int callerFileLine = 0) where T : Service
        {
            Func <Service, T> func = null;

            ServiceTopologyLog.Instance.Append(callerFilePath, memberName, callerFileLine);
            EnumValidator.ThrowIfInvalid <ClientAccessType>(clientAccessType, "clientAccessType");
            if (serviceFilter == null)
            {
                throw new ArgumentNullException("serviceFilter");
            }
            ServiceType serviceType = ServiceTopology.ServiceTypeMapper <T> .GetServiceType();

            List <Service> list = null;

            if (!this.services.TryGetValue(serviceType, out list) || list == null || list.Count <= 0)
            {
                return(default(T));
            }
            IEnumerable <Service> source = list.Where(delegate(Service service)
            {
                T t = (T)((object)service);
                return(t.ClientAccessType == clientAccessType && serviceFilter((T)((object)service)));
            });

            if (func == null)
            {
                func = ((Service service) => (T)((object)service));
            }
            List <T> list2 = source.Select(func).ToList <T>();

            if (list2.Count == 0)
            {
                return(default(T));
            }
            int index = ServiceTopology.Random.Next(list2.Count);

            return(list2[index]);
        }
예제 #12
0
        public BackEndServer GetDownLevelClientAccessServer <ServiceType>(AnchorMailbox anchorMailbox, BackEndServer mailboxServer, ClientAccessType clientAccessType, RequestDetailsLogger logger, bool calculateRedirectUrl, out Uri redirectUrl) where ServiceType : HttpService
        {
            if (anchorMailbox == null)
            {
                throw new ArgumentNullException("anchorMailbox");
            }
            if (mailboxServer == null)
            {
                throw new ArgumentNullException("mailboxServer");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (!DownLevelServerManager.IsApplicable)
            {
                throw new HttpProxyException(HttpStatusCode.NotFound, HttpProxySubErrorCode.EndpointNotFound, string.Format("{0} does not support down level server proxy.", HttpProxyGlobals.ProtocolType));
            }
            redirectUrl = null;
            if (mailboxServer.Version < Server.E14MinVersion)
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <int, int, string>((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServer]: Found mailbox server version {0}, which was pre-E14 minimum version {1}, so returning mailbox server FQDN {2}", mailboxServer.Version, Server.E14MinVersion, mailboxServer.Fqdn);
                return(mailboxServer);
            }
            ServiceTopology currentLegacyServiceTopology = ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServer", 393);
            Site            site   = currentLegacyServiceTopology.GetSite(mailboxServer.Fqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServer", 394);
            ServiceType     result = this.GetClientAccessServiceInSite <ServiceType>(currentLegacyServiceTopology, anchorMailbox, site, clientAccessType, (ServiceType service) => service.ServerVersionNumber >= Server.E14MinVersion && service.ServerVersionNumber < Server.E15MinVersion, logger);

            if (calculateRedirectUrl && !Utilities.IsPartnerHostedOnly && !VariantConfiguration.InvariantNoFlightingSnapshot.Cafe.NoCrossSiteRedirect.Enabled && result != null && !string.IsNullOrEmpty(result.ServerFullyQualifiedDomainName))
            {
                Site member = HttpProxyGlobals.LocalSite.Member;
                if (!member.DistinguishedName.Equals(result.Site.DistinguishedName))
                {
                    HttpService httpService = currentLegacyServiceTopology.FindAny <ServiceType>(ClientAccessType.External, (ServiceType externalService) => externalService != null && externalService.ServerFullyQualifiedDomainName.Equals(result.ServerFullyQualifiedDomainName, StringComparison.OrdinalIgnoreCase), "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServer", 419);
                    if (httpService != null)
                    {
                        redirectUrl = httpService.Url;
                    }
                }
            }
            return(new BackEndServer(result.ServerFullyQualifiedDomainName, result.ServerVersionNumber));
        }
예제 #13
0
        private ServiceType GetClientAccessServiceInSite <ServiceType>(ServiceTopology topology, AnchorMailbox anchorMailbox, Site targetSite, ClientAccessType clientAccessType, Predicate <ServiceType> otherFilter, RequestDetailsLogger logger) where ServiceType : HttpService
        {
            Dictionary <string, List <DownLevelServerStatusEntry> > downLevelServerMap = this.GetDownLevelServerMap();
            List <DownLevelServerStatusEntry> serverList = null;

            if (!downLevelServerMap.TryGetValue(targetSite.DistinguishedName, out serverList))
            {
                string text = string.Format("Unable to find site {0} in the down level server map.", targetSite.DistinguishedName);
                ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceInSite]: {0}", text);
                ThreadPool.QueueUserWorkItem(delegate(object o)
                {
                    this.RefreshServerMap(true);
                });
                throw new NoAvailableDownLevelBackEndException(text);
            }
            return(this.GetClientAccessServiceFromList <ServiceType>(serverList, topology, anchorMailbox, targetSite, clientAccessType, otherFilter, logger, DownLevelServerManager.DownlevelExchangeServerVersion.Exchange2010));
        }
예제 #14
0
 public static bool TryCreateMapiHttpService(MiniVirtualDirectory virtualDirectory, TopologyServerInfo serverInfo, Uri url, ClientAccessType clientAccessType, AuthenticationMethod authenticationMethod, out Service service)
 {
     EnumValidator.ThrowIfInvalid <ClientAccessType>(clientAccessType, "clientAccessType");
     if (virtualDirectory.IsMapi)
     {
         service = new MapiHttpService(serverInfo, url, clientAccessType, virtualDirectory);
         return(true);
     }
     service = null;
     return(false);
 }
예제 #15
0
        public BackEndServer GetDownLevelClientAccessServerWithPreferredServer <ServiceType>(AnchorMailbox anchorMailbox, string preferredCasServerFqdn, ClientAccessType clientAccessType, RequestDetailsLogger logger, int destinationVersion) where ServiceType : HttpService
        {
            Predicate <ServiceType> predicate  = null;
            Predicate <ServiceType> predicate2 = null;

            if (anchorMailbox == null)
            {
                throw new ArgumentNullException("anchorMailbox");
            }
            if (string.IsNullOrEmpty(preferredCasServerFqdn))
            {
                throw new ArgumentException("preferredCasServerFqdn cannot be empty!");
            }
            ServiceTopology currentLegacyServiceTopology = ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServerWithPreferredServer", 253);
            Site            site = currentLegacyServiceTopology.GetSite(preferredCasServerFqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServerWithPreferredServer", 254);
            Dictionary <string, List <DownLevelServerStatusEntry> > downLevelServerMap = this.GetDownLevelServerMap();
            List <DownLevelServerStatusEntry> list = null;

            if (!downLevelServerMap.TryGetValue(site.DistinguishedName, out list))
            {
                string text = string.Format("Unable to find site {0} in the down level server map.", site.DistinguishedName);
                ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServerWithPreferredServer]: {0}", text);
                ThreadPool.QueueUserWorkItem(delegate(object o)
                {
                    this.RefreshServerMap(true);
                });
                throw new NoAvailableDownLevelBackEndException(text);
            }
            DownLevelServerStatusEntry downLevelServerStatusEntry = list.Find((DownLevelServerStatusEntry backend) => preferredCasServerFqdn.Equals(backend.BackEndServer.Fqdn, StringComparison.OrdinalIgnoreCase));

            if (downLevelServerStatusEntry == null)
            {
                string text2 = string.Format("Unable to find preferred server {0} in the back end server map.", preferredCasServerFqdn);
                ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServerWithPreferredServer]: {0}", text2);
                throw new NoAvailableDownLevelBackEndException(text2);
            }
            if (downLevelServerStatusEntry.IsHealthy)
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <DownLevelServerStatusEntry>((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServerWithPreferredServer]: The preferred server {0} is healthy.", downLevelServerStatusEntry);
                return(downLevelServerStatusEntry.BackEndServer);
            }
            ServiceType serviceType = default(ServiceType);

            if (destinationVersion < Server.E14MinVersion)
            {
                try
                {
                    List <DownLevelServerStatusEntry> serverList = list;
                    ServiceTopology topology   = currentLegacyServiceTopology;
                    Site            targetSite = site;
                    if (predicate == null)
                    {
                        predicate = ((ServiceType service) => service.ServerVersionNumber >= Server.E2007MinVersion && service.ServerVersionNumber < Server.E14MinVersion);
                    }
                    serviceType = this.GetClientAccessServiceFromList <ServiceType>(serverList, topology, anchorMailbox, targetSite, clientAccessType, predicate, logger, DownLevelServerManager.DownlevelExchangeServerVersion.Exchange2007);
                }
                catch (NoAvailableDownLevelBackEndException)
                {
                    ExTraceGlobals.VerboseTracer.TraceError((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServerWithPreferredServer]: No E12 CAS could be found for E12 destination. Looking for E14 CAS.");
                }
            }
            if (serviceType == null)
            {
                List <DownLevelServerStatusEntry> serverList2 = list;
                ServiceTopology topology2   = currentLegacyServiceTopology;
                Site            targetSite2 = site;
                if (predicate2 == null)
                {
                    predicate2 = ((ServiceType service) => service.ServerVersionNumber >= Server.E14MinVersion && service.ServerVersionNumber < Server.E15MinVersion);
                }
                serviceType = this.GetClientAccessServiceFromList <ServiceType>(serverList2, topology2, anchorMailbox, targetSite2, clientAccessType, predicate2, logger, DownLevelServerManager.DownlevelExchangeServerVersion.Exchange2010);
            }
            return(new BackEndServer(serviceType.ServerFullyQualifiedDomainName, serviceType.ServerVersionNumber));
        }
예제 #16
0
 private Imap4Service(TopologyServerInfo serverInfo, ClientAccessType clientAccessType, AuthenticationMethod authenticationMethod, MiniEmailTransport emailTransport) : base(serverInfo, ServiceType.Imap4, clientAccessType, authenticationMethod, emailTransport)
 {
 }
예제 #17
0
 private MapiHttpService(TopologyServerInfo serverInfo, Uri url, ClientAccessType clientAccessType, MiniVirtualDirectory virtualDirectory) : base(serverInfo, ServiceType.MapiHttp, url, clientAccessType, AuthenticationMethod.None, virtualDirectory)
 {
     this.LastConfigurationTime = (virtualDirectory.WhenChangedUTC ?? (virtualDirectory.WhenCreatedUTC ?? DateTime.MinValue));
 }
예제 #18
0
        internal static BackEndServer GetAnyBackEndServerForVersion <ServiceType>(ServerVersion serverVersion, bool exactVersionMatch, ClientAccessType clientAccessType, bool currentSiteOnly = false) where ServiceType : HttpService
        {
            if (serverVersion == null)
            {
                throw new ArgumentNullException("version");
            }
            ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 349);
            string          empty               = string.Empty;
            int             version             = 0;
            ServerRole      serverRoleToLookFor = (serverVersion.Major < 15) ? ServerRole.ClientAccess : ServerRole.Mailbox;

            if (currentServiceTopology.TryGetRandomServerFromCurrentSite(serverRoleToLookFor, serverVersion.ToInt(), ServiceTopology.RandomServerSearchType.ExactVersion, out empty, out version, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 358))
            {
                return(new BackEndServer(empty, version));
            }
            if (!exactVersionMatch)
            {
                ServerVersion serverVersion2 = new ServerVersion(serverVersion.Major, 0, 0, 0);
                if (currentServiceTopology.TryGetRandomServerFromCurrentSite(serverRoleToLookFor, serverVersion2.ToInt(), ServiceTopology.RandomServerSearchType.MinimumVersionMatchMajor, out empty, out version, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 374))
                {
                    return(new BackEndServer(empty, version));
                }
            }
            if (!currentSiteOnly)
            {
                HttpService httpService = currentServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && !service.IsFrontEnd && (service.ServerRole & serverRoleToLookFor) == serverRoleToLookFor && !service.IsOutOfService && service.AdminDisplayVersionNumber == serverVersion, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 389);
                if (httpService != null)
                {
                    return(new BackEndServer(httpService.ServerFullyQualifiedDomainName, httpService.ServerVersionNumber));
                }
                if (!exactVersionMatch)
                {
                    new ServerVersion(serverVersion.Major, 0, 0, 0);
                    httpService = currentServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && !service.IsFrontEnd && (service.ServerRole & serverRoleToLookFor) == serverRoleToLookFor && !service.IsOutOfService && service.ServerVersionNumber > serverVersion.ToInt() && new ServerVersion(service.ServerVersionNumber).Major == serverVersion.Major, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 408);
                    if (httpService != null)
                    {
                        return(new BackEndServer(httpService.ServerFullyQualifiedDomainName, httpService.ServerVersionNumber));
                    }
                }
            }
            if (!exactVersionMatch)
            {
                ServerVersion higherVersion = new ServerVersion(serverVersion.Major + 1, 0, 0, 0);
                ServerRole    higherVersionServerRoleToLookFor = (higherVersion.Major < 15) ? ServerRole.ClientAccess : ServerRole.Mailbox;
                if (currentServiceTopology.TryGetRandomServerFromCurrentSite(higherVersionServerRoleToLookFor, higherVersion.ToInt(), ServiceTopology.RandomServerSearchType.MinimumVersion, out empty, out version, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 431))
                {
                    return(new BackEndServer(empty, version));
                }
                if (!currentSiteOnly)
                {
                    HttpService httpService2 = currentServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && !service.IsFrontEnd && (service.ServerRole & higherVersionServerRoleToLookFor) == higherVersionServerRoleToLookFor && !service.IsOutOfService && service.ServerVersionNumber > higherVersion.ToInt(), "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 444);
                    if (httpService2 != null)
                    {
                        return(new BackEndServer(httpService2.ServerFullyQualifiedDomainName, httpService2.ServerVersionNumber));
                    }
                }
            }
            string message = string.Format("Unable to find any backend server for version {0}.", serverVersion);

            throw new ServerNotFoundException(message, serverVersion.ToString());
        }
예제 #19
0
 internal static bool TryCreateImap4Service(MiniEmailTransport emailTransport, TopologyServerInfo serverInfo, ClientAccessType clientAccessType, AuthenticationMethod authenticationMethod, out Service service)
 {
     if (emailTransport.IsImap4)
     {
         service = new Imap4Service(serverInfo, clientAccessType, authenticationMethod, emailTransport);
         return(true);
     }
     service = null;
     return(false);
 }
예제 #20
0
        private ServiceType GetClientAccessServiceFromList <ServiceType>(List <DownLevelServerStatusEntry> serverList, ServiceTopology topology, AnchorMailbox anchorMailbox, Site targetSite, ClientAccessType clientAccessType, Predicate <ServiceType> otherFilter, RequestDetailsLogger logger, DownLevelServerManager.DownlevelExchangeServerVersion targetDownlevelExchangeServerVersion) where ServiceType : HttpService
        {
            string text     = anchorMailbox.ToCookieKey();
            int    hashCode = HttpProxyBackEndHelper.GetHashCode(text);

            serverList = this.GetFilteredServerListByVersion(serverList, targetDownlevelExchangeServerVersion);
            int[] shuffledList = DownLevelServerManager.GetShuffledList(serverList.Count, hashCode);
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(TraceType.DebugTrace))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string, int, string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: HashKey: {0}, HashCode: {1}, Anchor mailbox {2}.", text, hashCode, anchorMailbox.ToString());
            }
            for (int i = 0; i < shuffledList.Length; i++)
            {
                int num = shuffledList[i];
                DownLevelServerStatusEntry currentServer = serverList[num];
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug <string, int, bool>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: Back end server {0} is selected by current index {1}. IsHealthy = {2}", currentServer.BackEndServer.Fqdn, num, currentServer.IsHealthy);
                }
                if (currentServer.IsHealthy)
                {
                    ServiceType serviceType = topology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && service.ServerFullyQualifiedDomainName.Equals(currentServer.BackEndServer.Fqdn, StringComparison.OrdinalIgnoreCase) && !service.IsOutOfService && otherFilter(service), "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetClientAccessServiceFromList", 767);
                    if (serviceType != null)
                    {
                        ExTraceGlobals.VerboseTracer.TraceDebug <Uri, string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: Found service {0} matching back end server {1}.", serviceType.Url, currentServer.BackEndServer.Fqdn);
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(logger, "DownLevelTargetRandomHashing", string.Format("{0}/{1}", i, serverList.Count));

                        return(serviceType);
                    }
                    ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: Back end server {0} cannot be found by ServiceDiscovery.", currentServer.BackEndServer.Fqdn);
                }
                else
                {
                    ExTraceGlobals.VerboseTracer.TraceWarning <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: Back end server {0} is marked as unhealthy.", currentServer.BackEndServer.Fqdn);
                }
            }
            RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(logger, "DownLevelTargetRandomHashingFailure", string.Format("{0}", serverList.Count));

            this.TriggerServerMapRefreshIfNeeded(topology, serverList);
            string text2 = string.Format("Unable to find proper back end service for {0} in site {1}.", anchorMailbox, targetSite.DistinguishedName);

            ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: {0}", text2);
            throw new NoAvailableDownLevelBackEndException(text2);
        }
예제 #21
0
 internal HttpService(TopologyServerInfo serverInfo, ServiceType serviceType, Uri url, ClientAccessType clientAccessType, AuthenticationMethod authenticationMethod, MiniVirtualDirectory virtualDirectory) : base(serverInfo, serviceType, clientAccessType, authenticationMethod)
 {
     this.Url        = url;
     this.IsFrontEnd = HttpService.IsFrontEndRole(virtualDirectory, serverInfo);
     this.ADObjectId = virtualDirectory.Id;
 }
 // Token: 0x06000153 RID: 339 RVA: 0x000074D0 File Offset: 0x000056D0
 public ServerVersionAnchorMailbox(ServerVersion serverVersion, ClientAccessType clientAccessType, IRequestContext requestContext) : base(AnchorSource.ServerVersion, serverVersion, requestContext)
 {
     this.ClientAccessType         = clientAccessType;
     base.NotFoundExceptionCreator = (() => new ServerNotFoundException(string.Format("Cannot find Mailbox server with {0}.", this.ServerVersion), this.ServerVersion.ToString()));
 }
예제 #23
0
        private static ServiceType GetBestBackEndServiceForVersion <ServiceType>(HttpProxyBackEndHelper.TopologyWithSites topology, ClientAccessType clientAccessType, Predicate <int> versionNumberCondition) where ServiceType : HttpService
        {
            if (topology == null)
            {
                throw new ArgumentNullException("topology");
            }
            if (versionNumberCondition == null)
            {
                throw new ArgumentNullException("versionNumberCondition");
            }
            ServiceType serviceType = default(ServiceType);
            Site        lookupSite  = (topology.TargetSite != null) ? topology.TargetSite : topology.CurrentSite;

            if (lookupSite != null)
            {
                serviceType = topology.ServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && service.Site.Equals(lookupSite) && !service.IsOutOfService && versionNumberCondition(service.ServerVersionNumber), "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetBestBackEndServiceForVersion", 847);
                if (serviceType == null)
                {
                    ExTraceGlobals.CafeTracer.TraceError <Site>(0L, "[HttpProxyBackEndHelper.GetBestBackEndServiceForVersion] Could not find server for site {0}", lookupSite);
                }
            }
            if (serviceType == null && topology.CurrentSite != null)
            {
                serviceType = topology.ServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && service.Site.Equals(topology.CurrentSite) && !service.IsOutOfService && versionNumberCondition(service.ServerVersionNumber), "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetBestBackEndServiceForVersion", 870);
                if (serviceType == null)
                {
                    ExTraceGlobals.CafeTracer.TraceError <Site>(0L, "[HttpProxyBackEndHelper.GetBestBackEndServiceForVersion] Could not find server for current site {0}!", topology.CurrentSite);
                }
            }
            if (serviceType == null)
            {
                serviceType = topology.ServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && !service.IsOutOfService && versionNumberCondition(service.ServerVersionNumber), "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetBestBackEndServiceForVersion", 893);
                if (serviceType == null)
                {
                    ExTraceGlobals.CafeTracer.TraceError(0L, "[HttpProxyBackEndHelper.GetBestBackEndServiceForVersion] Could not find any applicable CAS server!  (Last chance - returning null.");
                }
            }
            if (serviceType == null)
            {
                throw new ServerNotFoundException("Unable to find proper HTTP service.");
            }
            return(serviceType);
        }
예제 #24
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.");
 }
예제 #25
0
        private static ServiceType[] FindAcceptableBackEndService <ServiceType>(HttpProxyBackEndHelper.TopologyWithSites topology, ClientAccessType clientAccessType, Predicate <int> versionNumberCondition) where ServiceType : HttpService
        {
            if (topology == null)
            {
                throw new ArgumentNullException("topology");
            }
            if (versionNumberCondition == null)
            {
                throw new ArgumentNullException("versionNumberCondition");
            }
            List <ServiceType> tempServices = new List <ServiceType>();
            Site lookupSite = (topology.TargetSite != null) ? topology.TargetSite : topology.CurrentSite;

            if (lookupSite != null)
            {
                topology.ServiceTopology.ForEach <ServiceType>(delegate(ServiceType service)
                {
                    if ((service.ServerRole & ServerRole.Mailbox) == ServerRole.Mailbox && service.ClientAccessType == clientAccessType && !service.IsOutOfService && service.Site.Equals(lookupSite) && versionNumberCondition(service.ServerVersionNumber))
                    {
                        tempServices.Add(service);
                    }
                }, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "FindAcceptableBackEndService", 948);
                if (tempServices.Count == 0)
                {
                    ExTraceGlobals.CafeTracer.TraceError <Site>(0L, "[HttpProxyBackEndHelper.FindAcceptableBackEndService] Could not find BE server for site {0}", lookupSite);
                }
            }
            if (tempServices.Count == 0 && topology.CurrentSite != null)
            {
                topology.ServiceTopology.ForEach <ServiceType>(delegate(ServiceType service)
                {
                    if ((service.ServerRole & ServerRole.Mailbox) == ServerRole.Mailbox && service.ClientAccessType == clientAccessType && !service.IsOutOfService && service.Site.Equals(topology.CurrentSite) && versionNumberCondition(service.ServerVersionNumber))
                    {
                        tempServices.Add(service);
                    }
                }, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "FindAcceptableBackEndService", 974);
                if (tempServices.Count == 0)
                {
                    ExTraceGlobals.CafeTracer.TraceError <Site>(0L, "[HttpProxyBackEndHelper.FindAcceptableBackEndService] Could not find BE server for current site {0}", topology.CurrentSite);
                }
            }
            if (tempServices.Count == 0)
            {
                topology.ServiceTopology.ForEach <ServiceType>(delegate(ServiceType service)
                {
                    if ((service.ServerRole & ServerRole.Mailbox) == ServerRole.Mailbox && service.ClientAccessType == clientAccessType && !service.IsOutOfService && versionNumberCondition(service.ServerVersionNumber))
                    {
                        tempServices.Add(service);
                    }
                }, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "FindAcceptableBackEndService", 999);
                if (tempServices.Count == 0)
                {
                    ExTraceGlobals.CafeTracer.TraceError(0L, "[HttpProxyBackEndHelper.FindAcceptableBackEndService] Could not find any applicable BE server");
                }
            }
            return(tempServices.ToArray());
        }
예제 #26
0
 internal static Service CreateSmtpService(MiniReceiveConnector smtpReceiveConnector, TopologyServerInfo serverInfo, ClientAccessType clientAccessType)
 {
     foreach (ServiceTypeInfo serviceTypeInfo in ServiceTypeInfo.serviceTypeInfos)
     {
         ServiceTypeInfo.TryCreateSmtpServiceDelegate tryCreateSmtpServiceDelegate = serviceTypeInfo.tryCreateServiceDelegate as ServiceTypeInfo.TryCreateSmtpServiceDelegate;
         if (tryCreateSmtpServiceDelegate != null)
         {
             Service service;
             Service result;
             if (tryCreateSmtpServiceDelegate(smtpReceiveConnector, serverInfo, clientAccessType, out service))
             {
                 result = service;
             }
             else
             {
                 result = null;
             }
             return(result);
         }
     }
     throw new InvalidOperationException(ServerStrings.ExInvalidServiceType);
 }
 // Token: 0x06000154 RID: 340 RVA: 0x000074F5 File Offset: 0x000056F5
 public ServerVersionAnchorMailbox(ServerVersion serverVersion, ClientAccessType clientAccessType, bool exactVersionMatch, IRequestContext requestContext) : this(serverVersion, clientAccessType, requestContext)
 {
     this.ExactVersionMatch = exactVersionMatch;
 }
예제 #28
0
 internal static Service CreateHttpService(MiniVirtualDirectory virtualDirectory, TopologyServerInfo serverInfo, Uri url, ClientAccessType clientAccessType, AuthenticationMethod authenticationMethod)
 {
     foreach (ServiceTypeInfo serviceTypeInfo in ServiceTypeInfo.serviceTypeInfos)
     {
         ServiceTypeInfo.TryCreateHttpServiceDelegate tryCreateHttpServiceDelegate = serviceTypeInfo.tryCreateServiceDelegate as ServiceTypeInfo.TryCreateHttpServiceDelegate;
         Service result;
         if (tryCreateHttpServiceDelegate != null && tryCreateHttpServiceDelegate(virtualDirectory, serverInfo, url, clientAccessType, authenticationMethod, out result))
         {
             return(result);
         }
     }
     throw new InvalidOperationException(ServerStrings.ExInvalidServiceType);
 }
예제 #29
0
 internal static bool TryCreateHttpService(MiniVirtualDirectory virtualDirectory, TopologyServerInfo serverInfo, Uri url, ClientAccessType clientAccessType, AuthenticationMethod authenticationMethod, out Service service)
 {
     service = new HttpService(serverInfo, ServiceType.Invalid, url, clientAccessType, authenticationMethod, virtualDirectory);
     return(true);
 }
예제 #30
0
 internal static Service CreateEmailTransportService(MiniEmailTransport emailTransport, TopologyServerInfo serverInfo, ClientAccessType clientAccessType, AuthenticationMethod authenticationMethod)
 {
     foreach (ServiceTypeInfo serviceTypeInfo in ServiceTypeInfo.serviceTypeInfos)
     {
         ServiceTypeInfo.TryCreateEmailTransportServiceDelegate tryCreateEmailTransportServiceDelegate = serviceTypeInfo.tryCreateServiceDelegate as ServiceTypeInfo.TryCreateEmailTransportServiceDelegate;
         Service result;
         if (tryCreateEmailTransportServiceDelegate != null && tryCreateEmailTransportServiceDelegate(emailTransport, serverInfo, clientAccessType, authenticationMethod, out result))
         {
             return(result);
         }
     }
     throw new InvalidOperationException(ServerStrings.ExInvalidServiceType);
 }