コード例 #1
0
        protected override void InternalProcessRecord()
        {
            base.InternalProcessRecord();
            if (base.HasErrors)
            {
                return;
            }
            Dictionary <TopologySite, List <TopologyServer> > dictionary = null;
            TopologySite topologySite = null;

            FederationCertificate.DiscoverServers(base.RootOrgGlobalConfigSession, false, out dictionary, out topologySite);
            if (topologySite == null)
            {
                base.WriteError(new CannotGetLocalSiteException(), ErrorCategory.ReadError, null);
            }
            foreach (KeyValuePair <TopologySite, List <TopologyServer> > keyValuePair in dictionary)
            {
                foreach (TopologyServer topologyServer in keyValuePair.Value)
                {
                    foreach (CertificateRecord certificateRecord in FederationCertificate.FederationCertificates(base.RootOrgGlobalConfigSession))
                    {
                        FederationTrustCertificateState  state          = FederationCertificate.TestForCertificate(topologyServer.Name, certificateRecord.Thumbprint);
                        FederationTrustCertificateStatus sendToPipeline = new FederationTrustCertificateStatus(keyValuePair.Key, topologyServer, state, certificateRecord.Thumbprint);
                        base.WriteObject(sendToPipeline);
                    }
                }
            }
        }
コード例 #2
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();
        }
コード例 #3
0
        // Token: 0x060050D4 RID: 20692 RVA: 0x0012C2F0 File Offset: 0x0012A4F0
        public List <TopologyServer> ServerList(TopologySite site)
        {
            List <TopologyServer> result;

            if (!this.siteDictionary.TryGetValue(site, out result))
            {
                result = new List <TopologyServer>();
            }
            return(result);
        }
コード例 #4
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);
        }
コード例 #5
0
        // Token: 0x060050D3 RID: 20691 RVA: 0x0012C298 File Offset: 0x0012A498
        public TopologySite ClosestSite(TopologySite sourceSite)
        {
            TopologySite topologySite = this.topo.FindClosestDestinationSite(sourceSite, this.siteList);

            if (topologySite != null)
            {
                this.siteList.Remove(topologySite);
            }
            ExTraceGlobals.RecipientUpdateServiceTracer.TraceDebug <string>((long)this.GetHashCode(), "ClosestSite returned site {0}.", (topologySite == null) ? "no site" : topologySite.Name);
            return(topologySite);
        }
コード例 #6
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();
        }
コード例 #7
0
        internal static void DiscoverServers(ITopologyConfigurationSession session, bool limitedSearch, out Dictionary <TopologySite, List <TopologyServer> > siteDictionary, out TopologySite localSite)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            ExchangeTopology exchangeTopology = ExchangeTopology.Discover(session, ExchangeTopologyScope.ServerAndSiteTopology);

            localSite      = exchangeTopology.LocalSite;
            siteDictionary = new Dictionary <TopologySite, List <TopologyServer> >();
            if (localSite == null)
            {
                return;
            }
            List <ITopologySite> list = new List <ITopologySite>();

            if (limitedSearch)
            {
                foreach (ITopologySiteLink topologySiteLink in localSite.TopologySiteLinks)
                {
                    foreach (ITopologySite item in topologySiteLink.TopologySites)
                    {
                        if (!list.Contains(item))
                        {
                            list.Add(item);
                        }
                    }
                }
            }
            foreach (TopologyServer topologyServer in exchangeTopology.AllTopologyServers)
            {
                if (topologyServer.TopologySite != null && FederationCertificate.IsServerQualifiedForFederationTrust(topologyServer) && (!limitedSearch || list.Contains(topologyServer.TopologySite)))
                {
                    List <TopologyServer> list2;
                    if (!siteDictionary.TryGetValue(topologyServer.TopologySite, out list2))
                    {
                        list2 = new List <TopologyServer>();
                        siteDictionary.Add(topologyServer.TopologySite, list2);
                    }
                    list2.Add(topologyServer);
                }
            }
        }
コード例 #8
0
        private static void PushCertificate(ITopologyConfigurationSession session, Server sourceServer, Task.TaskProgressLoggingDelegate writeProgress, Task.TaskWarningLoggingDelegate writeWarning, string thumbprint)
        {
            SecureString securePassword = FederationCertificate.GeneratePassword();

            FederationCertificate.EnableCertificateForNetworkService(sourceServer.Name, thumbprint);
            string base64cert = null;

            try
            {
                base64cert = FederationCertificate.ExportCertificate(sourceServer.Name, securePassword, thumbprint);
            }
            catch (InvalidOperationException)
            {
                writeWarning(Strings.WarningPushFailed(thumbprint));
                return;
            }
            catch (LocalizedException)
            {
                writeWarning(Strings.WarningPushFailed(thumbprint));
                return;
            }
            Dictionary <TopologySite, List <TopologyServer> > dictionary = null;
            TopologySite topologySite = null;

            FederationCertificate.DiscoverServers(session, true, out dictionary, out topologySite);
            if (topologySite != null)
            {
                List <TopologyServer> list;
                if (dictionary.TryGetValue(topologySite, out list))
                {
                    int count = list.Count;
                    int num   = 0;
                    foreach (TopologyServer topologyServer in list)
                    {
                        int percent = (int)((double)(++num) / (double)count * 100.0);
                        writeProgress(Strings.ProgressActivityPushFederationCertificate(thumbprint), Strings.ProgressActivityPushFederationServer(topologyServer.Name), percent);
                        if (!topologyServer.Id.Equals(sourceServer.Id))
                        {
                            try
                            {
                                FederationTrustCertificateState federationTrustCertificateState = FederationCertificate.TestForCertificate(topologyServer.Name, thumbprint);
                                if (federationTrustCertificateState == FederationTrustCertificateState.NotInstalled)
                                {
                                    FederationCertificate.ImportCertificate(topologyServer.Name, securePassword, base64cert);
                                }
                                if (federationTrustCertificateState != FederationTrustCertificateState.ServerUnreachable)
                                {
                                    FederationCertificate.EnableCertificateForNetworkService(topologyServer.Name, thumbprint);
                                }
                            }
                            catch (InvalidOperationException)
                            {
                                writeWarning(Strings.WarningPushCertificate(thumbprint, topologyServer.Name));
                            }
                            catch (LocalizedException)
                            {
                                writeWarning(Strings.WarningPushCertificate(thumbprint, topologyServer.Name));
                            }
                        }
                    }
                }
                return;
            }
            writeWarning(Strings.WarningCannotGetLocalSite(thumbprint));
        }
コード例 #9
0
        internal static PublicFolderDatabase FindClosestPublicFolderDatabase(IConfigDataProvider scSession, ADObjectId sourceServerId, Func <PublicFolderDatabase, bool> candidateMatcher)
        {
            if (scSession == null)
            {
                throw new ArgumentNullException("scSession");
            }
            PublicFolderDatabase result = null;

            PublicFolderDatabase[] array = (PublicFolderDatabase[])scSession.Find <PublicFolderDatabase>(null, null, true, null);
            if (candidateMatcher != null && 0 < array.Length)
            {
                array = array.Where(candidateMatcher).ToArray <PublicFolderDatabase>();
            }
            if (1 == array.Length)
            {
                result = array[0];
            }
            else if (array.Length > 1)
            {
                ExchangeTopology exchangeTopology = ExchangeTopology.Discover(null, ExchangeTopologyScope.ADAndExchangeServerAndSiteTopology);
                TopologySite     topologySite     = null;
                TopologySite     topologySite2    = null;
                if (sourceServerId == null)
                {
                    topologySite = exchangeTopology.LocalSite;
                }
                else
                {
                    string text   = null;
                    Server server = (Server)scSession.Read <Server>(sourceServerId);
                    if (server != null)
                    {
                        text = server.Fqdn;
                    }
                    if (!string.IsNullOrEmpty(text))
                    {
                        topologySite = exchangeTopology.SiteFromADServer(text);
                    }
                }
                if (topologySite != null)
                {
                    ReadOnlyCollection <TopologySite>         allTopologySites     = exchangeTopology.AllTopologySites;
                    ReadOnlyCollection <TopologySiteLink>     allTopologySiteLinks = exchangeTopology.AllTopologySiteLinks;
                    ReadOnlyCollection <TopologyServer>       allTopologyServers   = exchangeTopology.AllTopologyServers;
                    Dictionary <TopologyServer, TopologySite> dictionary           = new Dictionary <TopologyServer, TopologySite>();
                    foreach (TopologyServer topologyServer in allTopologyServers)
                    {
                        if (topologyServer.TopologySite != null)
                        {
                            foreach (TopologySite topologySite3 in allTopologySites)
                            {
                                if (topologySite3.DistinguishedName.Equals(topologyServer.TopologySite.DistinguishedName, StringComparison.OrdinalIgnoreCase))
                                {
                                    dictionary[topologyServer] = topologySite3;
                                    break;
                                }
                            }
                        }
                    }
                    Dictionary <TopologySite, PublicFolderDatabase> dictionary2 = new Dictionary <TopologySite, PublicFolderDatabase>();
                    List <TopologySite> list = new List <TopologySite>();
                    foreach (PublicFolderDatabase publicFolderDatabase in array)
                    {
                        foreach (KeyValuePair <TopologyServer, TopologySite> keyValuePair in dictionary)
                        {
                            if (keyValuePair.Key.DistinguishedName.Equals(publicFolderDatabase.Server.DistinguishedName, StringComparison.OrdinalIgnoreCase))
                            {
                                if (!dictionary2.ContainsKey(keyValuePair.Value))
                                {
                                    dictionary2[keyValuePair.Value] = publicFolderDatabase;
                                    list.Add(keyValuePair.Value);
                                    break;
                                }
                                if (keyValuePair.Key.IsExchange2007OrLater)
                                {
                                    dictionary2[keyValuePair.Value] = publicFolderDatabase;
                                    break;
                                }
                                break;
                            }
                        }
                    }
                    topologySite2 = exchangeTopology.FindClosestDestinationSite(topologySite, list);
                    if (topologySite2 != null)
                    {
                        result = dictionary2[topologySite2];
                    }
                }
                if (topologySite2 == null)
                {
                    result = array[0];
                }
            }
            return(result);
        }
コード例 #10
0
 public Site(TopologySite topologySite) : this(topologySite, new ServiceTopology.All(null))
 {
 }