private List <SmtpAddress> GetEnabledCrossPremiseRemoteDomainTargets(IConfigurationSession session)
        {
            List <SmtpAddress> list        = new List <SmtpAddress>();
            ADObjectId         adChildRoot = CrossPremiseTestMailFlowHelper.GetAdChildRoot(CrossPremiseTestMailFlowHelper.GetAdFirstOrgRoot(session, "Global Settings"), "Internet Message Formats");

            if (adChildRoot == null)
            {
                return(list);
            }
            IList <DomainContentConfig> list2;

            if (!CrossPremiseTestMailFlowHelper.TryLoadAdObjects <DomainContentConfig>(session, adChildRoot, out list2))
            {
                return(list);
            }
            foreach (DomainContentConfig domainContentConfig in list2)
            {
                if (!domainContentConfig.DomainName.IncludeSubDomains && domainContentConfig.TrustedMailOutboundEnabled)
                {
                    SmtpAddress item = new SmtpAddress("FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042", domainContentConfig.DomainName.Domain);
                    if (item.IsValidAddress)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
        internal static bool IsCrossPremise(IConfigurationSession session)
        {
            CrossPremiseTestMailFlowHelper crossPremiseTestMailFlowHelper = new CrossPremiseTestMailFlowHelper(null);
            ADObjectId         adFirstOrgRoot    = CrossPremiseTestMailFlowHelper.GetAdFirstOrgRoot(session, "Administrative Groups");
            List <SmtpAddress> siteEgressTargets = crossPremiseTestMailFlowHelper.GetSiteEgressTargets(session, adFirstOrgRoot);

            return(siteEgressTargets.Count <SmtpAddress>() != 0);
        }
        private bool IsFirstActiveMdbLocallyMounted()
        {
            IList <Database> list;

            if (!base.SourceMailboxServer.IsMailboxServer || !CrossPremiseTestMailFlowHelper.TryLoadAdObjects <Database>(base.Task.ConfigurationSession, this.adAdminGroups, out list))
            {
                return(false);
            }
            ActiveManager             cachingActiveManagerInstance = ActiveManager.GetCachingActiveManagerInstance();
            SortedList <Guid, string> sortedList = new SortedList <Guid, string>();

            try
            {
                foreach (Database database in list)
                {
                    DatabaseLocationInfo serverForDatabase = cachingActiveManagerInstance.GetServerForDatabase(database.Guid, GetServerForDatabaseFlags.None);
                    if (serverForDatabase != null && serverForDatabase.ServerSite != null && serverForDatabase.ServerSite.Equals(this.localSite) && !string.IsNullOrEmpty(serverForDatabase.ServerFqdn))
                    {
                        sortedList.Add(database.Guid, serverForDatabase.ServerFqdn);
                    }
                }
                using (IEnumerator <KeyValuePair <Guid, string> > enumerator2 = sortedList.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        KeyValuePair <Guid, string> kvp = enumerator2.Current;
                        Database database2 = list.ToList <Database>().Find(delegate(Database db)
                        {
                            Guid guid = db.Guid;
                            KeyValuePair <Guid, string> kvp3 = kvp;
                            return(guid == kvp3.Key);
                        });
                        Database mdb = database2;
                        KeyValuePair <Guid, string> kvp4 = kvp;
                        if (base.IsMdbMounted(mdb, kvp4.Value))
                        {
                            KeyValuePair <Guid, string> kvp2 = kvp;
                            return(kvp2.Value.Equals(base.SourceMailboxServer.Fqdn, StringComparison.OrdinalIgnoreCase));
                        }
                    }
                }
                return(false);
            }
            catch (ObjectNotFoundException ex)
            {
                base.Task.WriteWarning(Strings.CrossPremiseMapMdbToServerFailure(ex.ToString()));
            }
            catch (StoragePermanentException ex2)
            {
                base.Task.WriteWarning(Strings.CrossPremiseMapMdbToServerFailure(ex2.ToString()));
            }
            catch (StorageTransientException ex3)
            {
                base.Task.WriteWarning(Strings.CrossPremiseMapMdbToServerFailure(ex3.ToString()));
            }
            return(false);
        }
 internal override void InternalValidate()
 {
     base.InternalValidate();
     base.SetMonitoringDataSourceType("Cross Premise");
     base.SourceMailboxServer = ((ITopologyConfigurationSession)base.Task.ConfigurationSession).FindLocalServer();
     this.localSite           = base.SourceMailboxServer.ServerSite;
     this.adAdminGroups       = CrossPremiseTestMailFlowHelper.GetAdFirstOrgRoot(base.Task.ConfigurationSession, "Administrative Groups");
     base.IsRemoteTest        = true;
     this.localSystemMailbox  = base.GetServerSystemMailbox(base.SourceMailboxServer);
 }
        private List <SmtpAddress> GetSiteEgressTargets(IConfigurationSession session, ADObjectId adAdminGroups)
        {
            List <SmtpAddress> enabledCrossPremiseTargets = this.GetEnabledCrossPremiseTargets(session);
            IList <SmtpSendConnectorConfig> sendConnectors;

            if (enabledCrossPremiseTargets.Count == 0 || !CrossPremiseTestMailFlowHelper.TryLoadAdObjects <SmtpSendConnectorConfig>(session, adAdminGroups, out sendConnectors))
            {
                return(new List <SmtpAddress>());
            }
            IList <SmtpSendConnectorConfig> enabledSendConnectorsInSite = CrossPremiseTestMailFlowHelper.GetEnabledSendConnectorsInSite(base.Task.ConfigurationSession, this.localSite, sendConnectors);

            return(this.GetSiteEgressCrossPremiseTargets(enabledCrossPremiseTargets, sendConnectors, enabledSendConnectorsInSite));
        }
 private static ADObjectId GetAdFirstOrgRoot(IConfigurationSession session, string groupName)
 {
     return(CrossPremiseTestMailFlowHelper.GetAdChildRoot(session.GetOrgContainerId(), groupName));
 }