Ejemplo n.º 1
0
        internal Site(TopologySite topologySite, ServiceTopology.All all)
        {
            this.DistinguishedName = topologySite.DistinguishedName;
            all.Sites.Add(this.DistinguishedName, this);
            this.Id             = topologySite.Id;
            this.Guid           = topologySite.Guid;
            this.Name           = topologySite.Name;
            this.PartnerId      = topologySite.PartnerId;
            this.MinorPartnerId = topologySite.MinorPartnerId;
            List <ADObjectId> list = new List <ADObjectId>(topologySite.ResponsibleForSites);

            this.ResponsibleForSites = list.AsReadOnly();
            if (topologySite.TopologySiteLinks == null || topologySite.TopologySiteLinks.Count == 0)
            {
                this.SiteLinks = SiteLink.EmptyCollection;
                return;
            }
            List <SiteLink> list2 = new List <SiteLink>(topologySite.TopologySiteLinks.Count);

            foreach (ITopologySiteLink topologySiteLink in topologySite.TopologySiteLinks)
            {
                TopologySiteLink topologySiteLink2 = (TopologySiteLink)topologySiteLink;
                SiteLink         item = SiteLink.Get(topologySiteLink2, all);
                list2.Add(item);
            }
            this.SiteLinks = list2.AsReadOnly();
        }
Ejemplo n.º 2
0
        internal static Site Get(TopologySite topologySite, ServiceTopology.All all)
        {
            Site result;

            if (!all.Sites.TryGetValue(topologySite.DistinguishedName, out result))
            {
                result = new Site(topologySite, all);
            }
            return(result);
        }
Ejemplo n.º 3
0
        internal static SiteLink Get(TopologySiteLink topologySiteLink, ServiceTopology.All all)
        {
            SiteLink result;

            if (!all.SiteLinks.TryGetValue(topologySiteLink.DistinguishedName, out result))
            {
                result = new SiteLink(topologySiteLink, all);
            }
            return(result);
        }
Ejemplo n.º 4
0
        internal static TopologyServerInfo Get(TopologyServer server, ServiceTopology.All all)
        {
            TopologyServerInfo topologyServerInfo;

            if (!all.Servers.TryGetValue(server.DistinguishedName, out topologyServerInfo))
            {
                Site site = Site.Get(server.TopologySite, all);
                topologyServerInfo = new TopologyServerInfo(site, server);
                all.Servers.Add(topologyServerInfo.DistinguishedName, topologyServerInfo);
            }
            return(topologyServerInfo);
        }
Ejemplo n.º 5
0
        internal SiteLink(TopologySiteLink topologySiteLink, ServiceTopology.All all)
        {
            this.DistinguishedName = topologySiteLink.DistinguishedName;
            all.SiteLinks.Add(this.DistinguishedName, this);
            this.Name = topologySiteLink.Name;
            this.Cost = topologySiteLink.Cost;
            if (topologySiteLink.TopologySites == null || topologySiteLink.TopologySites.Count == 0)
            {
                this.Sites = Site.EmptyCollection;
                return;
            }
            List <Site> list = new List <Site>(topologySiteLink.TopologySites.Count);

            foreach (ITopologySite topologySite in topologySiteLink.TopologySites)
            {
                TopologySite topologySite2 = (TopologySite)topologySite;
                Site         item          = Site.Get(topologySite2, all);
                list.Add(item);
            }
            this.Sites = list.AsReadOnly();
        }
Ejemplo n.º 6
0
        internal ServiceTopology(ExchangeTopology topology, [CallerFilePath] string callerFilePath = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int callerFileLine = 0)
        {
            ServiceTopologyLog.Instance.Append(callerFilePath, memberName, callerFileLine);
            ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug((long)this.GetHashCode(), "ServiceTopology::Constructor. Creating a ServiceTopology object...");
            if (topology.LocalServer == null)
            {
                ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug((long)this.GetHashCode(), "ServiceTopology::ServiceTopology.ctor. Cannot find the local server from ExchangeTopology. topology.LocalServer == null.");
                throw new ServerNotFoundException(ServerStrings.ExServerNotFound("localhost"), "localhost");
            }
            string fqdn = topology.LocalServer.Fqdn;

            this.discoveryStarted = topology.DiscoveryStarted;
            Dictionary <string, TopologyServerInfo> dictionary = new Dictionary <string, TopologyServerInfo>(topology.AllTopologyServers.Count, StringComparer.OrdinalIgnoreCase);
            Dictionary <string, Site> dictionary2 = new Dictionary <string, Site>(topology.AllTopologyServers.Count, StringComparer.OrdinalIgnoreCase);
            List <string>             list        = new List <string>();
            Dictionary <Site, List <TopologyServerInfo> > dictionary3 = new Dictionary <Site, List <TopologyServerInfo> >(topology.AllTopologySites.Count);

            ServiceTopology.All all = new ServiceTopology.All(topology);
            foreach (TopologyServer topologyServer in topology.AllTopologyServers)
            {
                if (topologyServer.TopologySite != null)
                {
                    if (!dictionary2.ContainsKey(topologyServer.Fqdn))
                    {
                        TopologyServerInfo topologyServerInfo = TopologyServerInfo.Get(topologyServer, all);
                        Site site = topologyServerInfo.Site;
                        dictionary.Add(topologyServer.Fqdn, topologyServerInfo);
                        dictionary2.Add(topologyServer.Fqdn, site);
                        List <TopologyServerInfo> list2;
                        if (!dictionary3.TryGetValue(site, out list2))
                        {
                            list2 = new List <TopologyServerInfo>();
                            dictionary3.Add(site, list2);
                        }
                        list2.Add(topologyServerInfo);
                        ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug <string, string, Site>((long)this.GetHashCode(), "ServiceTopology::Constructor. Found Server in topology. ServerDn = {0}. Server Fqdn = {1}. Site = {2}.", topologyServer.DistinguishedName, topologyServer.Fqdn, site);
                    }
                    else
                    {
                        string arg = string.Empty;
                        foreach (KeyValuePair <string, TopologyServerInfo> keyValuePair in all.Servers)
                        {
                            if (keyValuePair.Value.ServerFullyQualifiedDomainName.Equals(topologyServer.Fqdn))
                            {
                                arg = keyValuePair.Key;
                                break;
                            }
                        }
                        ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "ServiceTopology::Constructor. There are two servers with the same fqdn in the topology. The second server was ignored. Fqdn = {0}. Server1Dn = {1}. Server2Dn = {2}.", topologyServer.Fqdn, arg, topologyServer.DistinguishedName);
                    }
                }
                else
                {
                    ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug <string>((long)this.GetHashCode(), "ServiceTopology::Constructor. Found a Server in the topology without a defined Site. Server = {0}.", topologyServer.DistinguishedName);
                    if (fqdn.Equals(topologyServer.Fqdn))
                    {
                        throw new ServerNotInSiteException(ServerStrings.ExCurrentServerNotInSite(fqdn), fqdn);
                    }
                    if (!list.Contains(topologyServer.Fqdn))
                    {
                        list.Add(topologyServer.Fqdn);
                    }
                }
            }
            Dictionary <ServiceType, List <Service> > serviceLists          = new Dictionary <ServiceType, List <Service> >();
            Dictionary <ServiceType, List <Service> > serviceLists2         = new Dictionary <ServiceType, List <Service> >();
            ReadOnlyCollection <MiniVirtualDirectory> allVirtualDirectories = topology.AllVirtualDirectories;

            if (allVirtualDirectories != null)
            {
                foreach (MiniVirtualDirectory miniVirtualDirectory in allVirtualDirectories)
                {
                    TopologyServerInfo serverInfo;
                    if (all.Servers.TryGetValue(miniVirtualDirectory.Server.DistinguishedName, out serverInfo))
                    {
                        if (HttpService.IsFrontEndRole(miniVirtualDirectory, serverInfo))
                        {
                            this.AddHttpServiceToDictionaries(fqdn, serviceLists2, serverInfo, miniVirtualDirectory, ClientAccessType.Unknown, null, AuthenticationMethod.None);
                        }
                        if (miniVirtualDirectory.InternalUrl != null)
                        {
                            AuthenticationMethod authenticationMethod = ServiceTopology.GetAuthenticationMethod(miniVirtualDirectory[MiniVirtualDirectorySchema.InternalAuthenticationMethodFlags]);
                            this.AddHttpServiceToDictionaries(fqdn, serviceLists, serverInfo, miniVirtualDirectory, ClientAccessType.Internal, miniVirtualDirectory.InternalUrl, authenticationMethod);
                        }
                        if (miniVirtualDirectory.IsWebServices && miniVirtualDirectory.InternalNLBBypassUrl != null)
                        {
                            AuthenticationMethod authenticationMethod2 = ServiceTopology.GetAuthenticationMethod(miniVirtualDirectory[MiniVirtualDirectorySchema.InternalAuthenticationMethodFlags]);
                            this.AddHttpServiceToDictionaries(fqdn, serviceLists, serverInfo, miniVirtualDirectory, ClientAccessType.InternalNLBBypass, miniVirtualDirectory.InternalNLBBypassUrl, authenticationMethod2);
                        }
                        if (miniVirtualDirectory.ExternalUrl != null)
                        {
                            AuthenticationMethod authenticationMethod3 = ServiceTopology.GetAuthenticationMethod(miniVirtualDirectory[MiniVirtualDirectorySchema.ExternalAuthenticationMethodFlags]);
                            this.AddHttpServiceToDictionaries(fqdn, serviceLists, serverInfo, miniVirtualDirectory, ClientAccessType.External, miniVirtualDirectory.ExternalUrl, authenticationMethod3);
                        }
                    }
                }
            }
            ReadOnlyCollection <MiniEmailTransport> allEmailTransports = topology.AllEmailTransports;

            if (allEmailTransports != null)
            {
                foreach (MiniEmailTransport miniEmailTransport in allEmailTransports)
                {
                    if (miniEmailTransport.IsPop3 || miniEmailTransport.IsImap4)
                    {
                        MiniEmailTransport miniEmailTransport2 = miniEmailTransport;
                        TopologyServerInfo topologyServerInfo2;
                        if (all.Servers.TryGetValue(miniEmailTransport2.Server.DistinguishedName, out topologyServerInfo2))
                        {
                            bool          flag          = miniEmailTransport2.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2010);
                            ServerVersion serverVersion = new ServerVersion(topologyServerInfo2.VersionNumber);
                            flag |= (VariantConfiguration.InvariantNoFlightingSnapshot.DataStorage.CheckR3Coexistence.Enabled && serverVersion.Major == Server.Exchange2009MajorVersion && serverVersion.Build == 482);
                            if ((miniEmailTransport2.InternalConnectionSettings != null && miniEmailTransport2.InternalConnectionSettings.Count > 0) || flag)
                            {
                                this.AddEmailTransportServiceToDictionaries(fqdn, serviceLists, topologyServerInfo2, miniEmailTransport2, ClientAccessType.Internal, AuthenticationMethod.None);
                            }
                            if ((miniEmailTransport2.ExternalConnectionSettings != null && miniEmailTransport2.ExternalConnectionSettings.Count > 0) || flag)
                            {
                                this.AddEmailTransportServiceToDictionaries(fqdn, serviceLists, topologyServerInfo2, miniEmailTransport2, ClientAccessType.External, AuthenticationMethod.None);
                            }
                        }
                    }
                }
            }
            ReadOnlyCollection <MiniReceiveConnector> allSmtpReceiveConnectors = topology.AllSmtpReceiveConnectors;

            if (allSmtpReceiveConnectors != null)
            {
                foreach (MiniReceiveConnector miniReceiveConnector in allSmtpReceiveConnectors)
                {
                    TopologyServerInfo serverInfo2;
                    if (all.Servers.TryGetValue(miniReceiveConnector.Server.DistinguishedName, out serverInfo2))
                    {
                        this.AddSmtpServiceToDictionaries(fqdn, serviceLists, serverInfo2, miniReceiveConnector, ClientAccessType.External);
                        this.AddSmtpServiceToDictionaries(fqdn, serviceLists, serverInfo2, miniReceiveConnector, ClientAccessType.Internal);
                    }
                }
            }
            Dictionary <string, Site> dictionary4 = new Dictionary <string, Site>(topology.AllTopologySites.Count, StringComparer.OrdinalIgnoreCase);

            foreach (TopologySite topologySite in topology.AllTopologySites)
            {
                dictionary4[topologySite.DistinguishedName] = Site.Get(topologySite, all);
            }
            this.localServerInfo        = TopologyServerInfo.Get(topology.LocalServer, all);
            this.serverToSiteDictionary = dictionary2;
            this.services                 = serviceLists;
            this.cafeServices             = serviceLists2;
            this.serversWithoutSite       = list;
            this.siteToServersDictionary  = dictionary3;
            this.siteDictionary           = dictionary4;
            this.serverFqdnDictionary     = dictionary;
            this.connectionCostCalculator = new ConnectionCostCalculator(topology.AllTopologySites.Count);
        }