Example #1
0
 // Token: 0x06004F85 RID: 20357 RVA: 0x00124E5B File Offset: 0x0012305B
 internal static ExchangeTopology Populate(ExchangeTopologyDiscovery topologyDiscovery)
 {
     topologyDiscovery.BuildInitialLinks();
     topologyDiscovery.MatchServersWithSites();
     topologyDiscovery.CreateTopology();
     ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, int>(0L, "PFD ADPEXT {0} - Exchange Topology discovery complete (hash code: {1})", 28341, topologyDiscovery.preparedTopology.GetHashCode());
     return(topologyDiscovery.preparedTopology);
 }
Example #2
0
        // Token: 0x06004F84 RID: 20356 RVA: 0x00124DF0 File Offset: 0x00122FF0
        internal static ExchangeTopologyDiscovery Create(ITopologyConfigurationSession session, ExchangeTopologyScope scope)
        {
            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, ExchangeTopologyScope, string>(0L, "PFD ADPEXT {0} - Exchange Topology discovery with scope {1} started using {2} AD session", 21429, scope, (session != null) ? "caller specified" : "internally created");
            if (session == null)
            {
                session = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 155, "Create", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\ExchangeTopology\\ExchangeTopologyDiscovery.cs");
            }
            ExchangeTopologyDiscovery exchangeTopologyDiscovery = new ExchangeTopologyDiscovery(DateTime.UtcNow, scope);

            exchangeTopologyDiscovery.ReadFromAD(session);
            return(exchangeTopologyDiscovery);
        }
Example #3
0
            // Token: 0x06004FA3 RID: 20387 RVA: 0x0012629C File Offset: 0x0012449C
            public static byte[][] Rescope(ExchangeTopologyScope topologyScope, byte[][] data)
            {
                byte[][] array = new byte[3][];
                data.CopyTo(array, 0);
                bool flag  = ExchangeTopologyDiscovery.IncludeServices(topologyScope);
                bool flag2 = ExchangeTopologyDiscovery.IncludeADServers(topologyScope);

                if (!flag)
                {
                    array[1] = new byte[12];
                }
                if (!flag2)
                {
                    array[2] = new byte[4];
                }
                return(array);
            }
Example #4
0
            // Token: 0x06004FA1 RID: 20385 RVA: 0x0012602C File Offset: 0x0012422C
            public static ExchangeTopologyDiscovery CreateFrom(ExchangeTopologyDiscovery.Simple topology)
            {
                ArgumentValidator.ThrowIfNull("topology", topology);
                ExchangeTopologyDiscovery exchangeTopologyDiscovery = new ExchangeTopologyDiscovery(topology.DiscoveryStarted, topology.TopologyScope);

                exchangeTopologyDiscovery.localServerFqdn       = topology.LocalServerFqdn;
                exchangeTopologyDiscovery.sites                 = SimpleADObject.CreateList <ADSite>(topology.Sites, ExchangeTopologyDiscovery.Simple.aDSiteSchema, null);
                exchangeTopologyDiscovery.siteLinks             = SimpleADObject.CreateList <ADSiteLink>(topology.SiteLinks, ExchangeTopologyDiscovery.Simple.aDSiteLinkSchema, null);
                exchangeTopologyDiscovery.servers               = SimpleADObject.CreateList <MiniTopologyServer>(topology.Servers, ExchangeTopologyDiscovery.Simple.serverSchema, null);
                exchangeTopologyDiscovery.virtualDirectories    = SimpleADObject.CreateList <MiniVirtualDirectory>(topology.VirtualDirectories, ExchangeTopologyDiscovery.Simple.virtualDirectorySchema, null);
                exchangeTopologyDiscovery.emailTransports       = SimpleADObject.CreateList <MiniEmailTransport>(topology.EmailTransports, ExchangeTopologyDiscovery.Simple.emailTransportSchema, null);
                exchangeTopologyDiscovery.smtpReceiveConnectors = SimpleADObject.CreateList <MiniReceiveConnector>(topology.SmtpReceiveConnectors, ExchangeTopologyDiscovery.Simple.receiveConnectorSchema, null);
                List <ADServer> list = SimpleADObject.CreateList <ADServer>(topology.ADServers, ExchangeTopologyDiscovery.Simple.aDServerSchema, null);

                exchangeTopologyDiscovery.aDServers = new ReadOnlyCollection <ADServer>(list);
                return(exchangeTopologyDiscovery);
            }
Example #5
0
 // Token: 0x06004FA0 RID: 20384 RVA: 0x00125F70 File Offset: 0x00124170
 public static ExchangeTopologyDiscovery.Simple CreateFrom(ExchangeTopologyDiscovery topologyDiscovery)
 {
     ArgumentValidator.ThrowIfNull("topologyDiscovery", topologyDiscovery);
     return(new ExchangeTopologyDiscovery.Simple
     {
         DiscoveryStarted = topologyDiscovery.discoveryStarted,
         TopologyScope = topologyDiscovery.topologyScope,
         LocalServerFqdn = topologyDiscovery.localServerFqdn,
         Sites = SimpleADObject.CreateList <ADSite>(topologyDiscovery.sites),
         SiteLinks = SimpleADObject.CreateList <ADSiteLink>(topologyDiscovery.siteLinks),
         Servers = SimpleADObject.CreateList <MiniTopologyServer>(topologyDiscovery.servers),
         VirtualDirectories = SimpleADObject.CreateList <MiniVirtualDirectory>(topologyDiscovery.virtualDirectories),
         EmailTransports = SimpleADObject.CreateList <MiniEmailTransport>(topologyDiscovery.emailTransports),
         SmtpReceiveConnectors = SimpleADObject.CreateList <MiniReceiveConnector>(topologyDiscovery.smtpReceiveConnectors),
         ADServers = SimpleADObject.CreateList <ADServer>(topologyDiscovery.aDServers)
     });
 }
Example #6
0
        // Token: 0x06004F8A RID: 20362 RVA: 0x00125C74 File Offset: 0x00123E74
        private void CreateTopology()
        {
            bool flag  = ExchangeTopologyDiscovery.IncludeServices(this.topologyScope);
            bool flag2 = ExchangeTopologyDiscovery.IncludeADServers(this.topologyScope);
            Dictionary <string, ReadOnlyCollection <ADServer> > dictionary = null;

            if (flag2)
            {
                dictionary = new Dictionary <string, ReadOnlyCollection <ADServer> >(this.topoSites.Count);
                foreach (string key in this.siteADServerDictionary.Keys)
                {
                    dictionary.Add(key, new ReadOnlyCollection <ADServer>(this.siteADServerDictionary[key]));
                }
            }
            this.preparedTopology = new ExchangeTopology(this.discoveryStarted, this.topologyScope, new ReadOnlyCollection <TopologyServer>(this.topoServers), new ReadOnlyCollection <TopologySite>(this.topoSites), new ReadOnlyCollection <TopologySiteLink>(this.topoSiteLinks), flag ? new ReadOnlyCollection <MiniVirtualDirectory>(this.virtualDirectories) : null, flag ? new ReadOnlyCollection <MiniEmailTransport>(this.emailTransports) : null, flag ? new ReadOnlyCollection <MiniReceiveConnector>(this.smtpReceiveConnectors) : null, flag2 ? this.aDServers : null, flag2 ? this.aDServerSiteDictionary : null, dictionary, this.siteDictionary, this.localServerFqdn);
            TimeSpan timeSpan = this.preparedTopology.WhenCreated - this.discoveryStarted;

            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, double>((long)this.GetHashCode(), "PFD ADPEXT {0} - It took {0} ms to create the Exchange topology", 20149, timeSpan.TotalMilliseconds);
            using (Process currentProcess = Process.GetCurrentProcess())
            {
                if (currentProcess != null)
                {
                    int num = 0;
                    foreach (TopologyServer topologyServer in this.topoServers)
                    {
                        if (topologyServer.TopologySite == null)
                        {
                            if (topologyServer.IsExchange2007OrLater)
                            {
                                num++;
                            }
                            else
                            {
                                ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string>(0L, "Server {0} belongs to no site because its version is Exchange 2003 or earlier.", topologyServer.Fqdn);
                            }
                        }
                    }
                    ExchangeTopologyPerformanceCountersInstance instance = ExchangeTopologyPerformanceCounters.GetInstance(currentProcess.Id.ToString());
                    instance.LastExchangeTopologyDiscoveryTimeSeconds.RawValue = (long)Math.Round(timeSpan.TotalSeconds);
                    instance.ExchangeTopologyDiscoveriesPerformed.Increment();
                    instance.SitelessServers.RawValue = (long)num;
                }
            }
        }
Example #7
0
        // Token: 0x06004F86 RID: 20358 RVA: 0x00124E98 File Offset: 0x00123098
        private void ReadFromAD(ITopologyConfigurationSession session)
        {
            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Reading topology-related objects from the Active Directory", 29621);
            this.sites                 = new List <ADSite>();
            this.siteLinks             = new List <ADSiteLink>();
            this.servers               = new List <MiniTopologyServer>();
            this.virtualDirectories    = new List <MiniVirtualDirectory>();
            this.emailTransports       = new List <MiniEmailTransport>();
            this.smtpReceiveConnectors = new List <MiniReceiveConnector>();
            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Getting the local computer FQDN", 21685);
            this.localServerFqdn = NativeHelpers.GetLocalComputerFqdn(true);
            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, string>(0L, "PFD ADPEXT {0} - Local computer FQDN is {1}", 29877, this.localServerFqdn);
            bool   flag  = ExchangeTopologyDiscovery.IncludeServices(this.topologyScope);
            bool   flag2 = ExchangeTopologyDiscovery.IncludeADServers(this.topologyScope);
            string text  = "CN=Sites," + session.ConfigurationNamingContext.DistinguishedName;

            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, string>(0L, "PFD ADPEXT {0} - Reading all Active Directory sites under {1}", 19637, text);
            ADObjectId             rootId        = new ADObjectId(text, Guid.Empty);
            ADPagedReader <ADSite> adpagedReader = session.FindPaged <ADSite>(rootId, QueryScope.OneLevel, null, null, 0);

            foreach (ADSite adsite in adpagedReader)
            {
                ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string>(0L, "Found site {0}", adsite.Name);
                this.sites.Add(adsite);
            }
            string text2 = "CN=IP,CN=Inter-Site Transports," + text;

            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, string>(0L, "PFD ADPEXT {0} - Reading all IP Active Directory site links under {1}", 23733, text2);
            ADPagedReader <ADSiteLink> adpagedReader2 = session.FindPaged <ADSiteLink>(new ADObjectId(text2, Guid.Empty), QueryScope.OneLevel, null, null, 0);

            foreach (ADSiteLink adsiteLink in adpagedReader2)
            {
                ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string>(0L, "Found site link {0}", adsiteLink.Name);
                this.siteLinks.Add(adsiteLink);
            }
            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Reading all Exchange servers from the Active Directory", 31925);
            ADPagedReader <MiniTopologyServer> adpagedReader3 = session.FindPaged <MiniTopologyServer>(session.ConfigurationNamingContext, QueryScope.SubTree, null, null, 0, null);

            foreach (MiniTopologyServer miniTopologyServer in adpagedReader3)
            {
                ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string>(0L, "Found server {0}", miniTopologyServer.Name);
                this.servers.Add(miniTopologyServer);
            }
            if (flag)
            {
                ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Reading all Exchange virtual directories from the Active Directory", 17589);
                ADPagedReader <MiniVirtualDirectory> adpagedReader4 = session.FindPaged <MiniVirtualDirectory>(session.ConfigurationNamingContext, QueryScope.SubTree, null, null, 0, null);
                foreach (MiniVirtualDirectory miniVirtualDirectory in adpagedReader4)
                {
                    ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string>(0L, "Found virtual directory {0}", miniVirtualDirectory.Name);
                    this.virtualDirectories.Add(miniVirtualDirectory);
                }
            }
            if (flag)
            {
                ADPagedReader <MiniEmailTransport> adpagedReader5 = session.FindPaged <MiniEmailTransport>(session.ConfigurationNamingContext, QueryScope.SubTree, null, null, 0, null);
                foreach (MiniEmailTransport miniEmailTransport in adpagedReader5)
                {
                    ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string>(0L, "Found email transport configuration {0}", miniEmailTransport.Name);
                    this.emailTransports.Add(miniEmailTransport);
                }
            }
            if (flag2)
            {
                ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Reading all Active Directory domain controllers", 25781);
                this.aDServers = session.FindServerWithNtdsdsa(null, false, false);
            }
            else
            {
                this.aDServers = new ReadOnlyCollection <ADServer>(new List <ADServer>());
            }
            if (flag)
            {
                QueryFilter filter = new AndFilter(new QueryFilter[]
                {
                    new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.ObjectCategory, "msExchSmtpReceiveConnector"),
                    new BitMaskAndFilter(ReceiveConnectorSchema.ProtocolOptions, 8192UL)
                });
                ADPagedReader <MiniReceiveConnector> adpagedReader6 = session.FindPaged <MiniReceiveConnector>(session.ConfigurationNamingContext, QueryScope.SubTree, filter, null, 0, null);
                foreach (MiniReceiveConnector miniReceiveConnector in adpagedReader6)
                {
                    ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string>(0L, "Found receive connector configuration {0}", miniReceiveConnector.Name);
                    this.smtpReceiveConnectors.Add(miniReceiveConnector);
                }
            }
        }
Example #8
0
        // Token: 0x06004F87 RID: 20359 RVA: 0x001252FC File Offset: 0x001234FC
        private void BuildInitialLinks()
        {
            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Creating topology objects and building links", 18613);
            this.aDServerSiteDictionary = new Dictionary <string, TopologySite>(StringComparer.OrdinalIgnoreCase);
            this.siteADServerDictionary = new Dictionary <string, List <ADServer> >(StringComparer.OrdinalIgnoreCase);
            this.topoSites      = new List <TopologySite>(this.sites.Count);
            this.topoSiteLinks  = new List <TopologySiteLink>(this.siteLinks.Count);
            this.siteDictionary = new Dictionary <string, TopologySite>(this.sites.Count, StringComparer.OrdinalIgnoreCase);
            this.topoServers    = new List <TopologyServer>(this.servers.Count);
            Dictionary <TopologySite, List <ITopologySiteLink> > dictionary = new Dictionary <TopologySite, List <ITopologySiteLink> >(this.sites.Count);
            bool flag = ExchangeTopologyDiscovery.IncludeADServers(this.topologyScope);

            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Creating TopologySites and hash them by site DN", 22709);
            foreach (ADSite site in this.sites)
            {
                TopologySite topologySite = new TopologySite(site);
                this.siteDictionary.Add(topologySite.DistinguishedName, topologySite);
                dictionary.Add(topologySite, new List <ITopologySiteLink>());
                this.topoSites.Add(topologySite);
            }
            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Creating TopologySiteLinks and filling the TopologySites collection", 30901);
            foreach (ADSiteLink adsiteLink in this.siteLinks)
            {
                TopologySiteLink     topologySiteLink = new TopologySiteLink(adsiteLink);
                List <ITopologySite> list             = new List <ITopologySite>(topologySiteLink.Sites.Count);
                foreach (ADObjectId adobjectId in topologySiteLink.Sites)
                {
                    TopologySite topologySite2 = null;
                    if (!this.siteDictionary.TryGetValue(adobjectId.DistinguishedName, out topologySite2))
                    {
                        ExTraceGlobals.ExchangeTopologyTracer.TraceWarning <string, string>(0L, "Site link {0} points to nonexistent site {1} (likely a transient replication issue). Ignoring this pointer.", adsiteLink.Name, adobjectId.DistinguishedName);
                    }
                    else
                    {
                        list.Add(topologySite2);
                        dictionary[topologySite2].Add(topologySiteLink);
                    }
                }
                topologySiteLink.TopologySites = new ReadOnlyCollection <ITopologySite>(list);
                this.topoSiteLinks.Add(topologySiteLink);
            }
            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Filling each site's TopologySiteLinks collection", 16565);
            foreach (TopologySite topologySite3 in this.topoSites)
            {
                List <ITopologySiteLink> list2 = null;
                if (!dictionary.TryGetValue(topologySite3, out list2))
                {
                    if (this.topoSites.Count > 1)
                    {
                        ExTraceGlobals.ExchangeTopologyTracer.TraceWarning <string>(0L, "Site {0} is not linked to any sites.", topologySite3.Name);
                    }
                    list2 = new List <ITopologySiteLink>();
                }
                topologySite3.TopologySiteLinks = new ReadOnlyCollection <ITopologySiteLink>(list2);
            }
            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Creating TopologyServers", 24757);
            foreach (MiniTopologyServer server in this.servers)
            {
                TopologyServer item = new TopologyServer(server);
                this.topoServers.Add(item);
            }
            if (flag)
            {
                ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Filling the ADServerSite dictionary with domain controller site mappings", 28853);
                foreach (ADServer adserver in this.aDServers)
                {
                    string       distinguishedName = adserver.Id.Parent.Parent.DistinguishedName;
                    TopologySite topologySite4;
                    if (!this.siteDictionary.TryGetValue(distinguishedName, out topologySite4))
                    {
                        ExTraceGlobals.ExchangeTopologyTracer.TraceWarning <string, string>(0L, "AD Server {0} points to nonexistent site {1} (likely a replication issue).", adserver.DnsHostName, distinguishedName);
                    }
                    else
                    {
                        this.aDServerSiteDictionary[adserver.DnsHostName] = topologySite4;
                        this.aDServerSiteDictionary[adserver.Name]        = topologySite4;
                        ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string, string>(0L, "ADServer {0} is assigned a static site {1}.", adserver.DnsHostName, topologySite4.Name);
                        List <ADServer> list3;
                        if (!this.siteADServerDictionary.TryGetValue(distinguishedName, out list3))
                        {
                            list3 = new List <ADServer>();
                            this.siteADServerDictionary.Add(distinguishedName, list3);
                            ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string>(0L, "Adding site {0} to the siteADServerDictionary.", topologySite4.Name);
                        }
                        list3.Add(adserver);
                        ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string, string>(0L, "Adding ADServer {0} to the siteADServerDictionary under site {1}.", adserver.DnsHostName, topologySite4.Name);
                    }
                }
            }
        }
Example #9
0
 public ReadOnlyCollection <TopologySite> GetSitesSortedByCostFromSite(TopologySite sourceSite)
 {
     return(new ReadOnlyCollection <TopologySite>(ExchangeTopologyDiscovery.OrderDestinationSites(this.allTopologySites, sourceSite, this.allTopologySites)));
 }
Example #10
0
        public static ExchangeTopology Discover(ITopologyConfigurationSession session, ExchangeTopologyScope scope)
        {
            ExchangeTopologyDiscovery topologyDiscovery = ExchangeTopologyDiscovery.Create(session, scope);

            return(ExchangeTopologyDiscovery.Populate(topologyDiscovery));
        }