// Token: 0x06000172 RID: 370 RVA: 0x0000A128 File Offset: 0x00008328
        private static SmtpAddress GetDiscoveryHolds(DiscoverySearchDataProvider dataProvider, Dictionary <string, MailboxDiscoverySearch> discoveryHolds)
        {
            SmtpAddress       smtpAddress     = SmtpAddress.Empty;
            ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), OrganizationId.ForestWideOrgId, null, false);
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 324, "GetDiscoveryHolds", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\elc\\DiscoveryHoldSynchronizer.cs");

            foreach (MailboxDiscoverySearch mailboxDiscoverySearch in dataProvider.GetAll <MailboxDiscoverySearch>())
            {
                if (mailboxDiscoverySearch.InPlaceHoldEnabled)
                {
                    discoveryHolds.Add(mailboxDiscoverySearch.InPlaceHoldIdentity, mailboxDiscoverySearch);
                    if (smtpAddress == SmtpAddress.Empty)
                    {
                        Result <ADRawEntry>[] first = tenantOrRootOrgRecipientSession.FindByLegacyExchangeDNs(mailboxDiscoverySearch.Sources.ToArray(), new ADPropertyDefinition[]
                        {
                            ADRecipientSchema.RecipientType,
                            ADRecipientSchema.RecipientTypeDetails,
                            ADUserSchema.ArchiveDomain,
                            ADUserSchema.ArchiveGuid,
                            ADRecipientSchema.RawExternalEmailAddress,
                            ADUserSchema.ArchiveStatus
                        });
                        foreach (ADRawEntry adrawEntry in from x in first
                                 select x.Data)
                        {
                            if (adrawEntry != null)
                            {
                                RecipientType        recipientType        = (RecipientType)adrawEntry[ADRecipientSchema.RecipientType];
                                RecipientTypeDetails recipientTypeDetails = (RecipientTypeDetails)adrawEntry[ADRecipientSchema.RecipientTypeDetails];
                                SmtpDomain           smtpDomain           = (SmtpDomain)adrawEntry[ADUserSchema.ArchiveDomain];
                                ArchiveStatusFlags   archiveStatusFlags   = (ArchiveStatusFlags)adrawEntry[ADUserSchema.ArchiveStatus];
                                if (RemoteMailbox.IsRemoteMailbox(recipientTypeDetails))
                                {
                                    smtpAddress = new SmtpAddress(((ProxyAddress)adrawEntry[ADRecipientSchema.RawExternalEmailAddress]).AddressString);
                                }
                                else if (recipientType == RecipientType.UserMailbox && smtpDomain != null && !string.IsNullOrEmpty(smtpDomain.Domain) && (archiveStatusFlags & ArchiveStatusFlags.Active) == ArchiveStatusFlags.Active)
                                {
                                    Guid guid = (Guid)adrawEntry[ADUserSchema.ArchiveGuid];
                                    if (guid != Guid.Empty)
                                    {
                                        smtpAddress = new SmtpAddress(SmtpProxyAddress.EncapsulateExchangeGuid(smtpDomain.Domain, guid));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(smtpAddress);
        }
        // Token: 0x06000153 RID: 339 RVA: 0x00008BFC File Offset: 0x00006DFC
        private Dictionary <string, InPlaceHoldConfiguration> LoadInPlaceHoldConfigurationInOrg(OrganizationId orgId, StatisticsLogEntry logEntry)
        {
            this.TraceInformation("Load All hold policy Objects in Organization " + orgId);
            new List <InPlaceHoldConfiguration>();
            DiscoverySearchDataProvider                   discoverySearchDataProvider = new DiscoverySearchDataProvider(orgId);
            IEnumerable <MailboxDiscoverySearch>          all        = discoverySearchDataProvider.GetAll <MailboxDiscoverySearch>();
            Dictionary <string, InPlaceHoldConfiguration> dictionary = new Dictionary <string, InPlaceHoldConfiguration>();

            foreach (MailboxDiscoverySearch mailboxDiscoverySearch in all)
            {
                if (!dictionary.ContainsKey(mailboxDiscoverySearch.InPlaceHoldIdentity))
                {
                    InPlaceHoldConfiguration value = new InPlaceHoldConfiguration(mailboxDiscoverySearch);
                    dictionary.Add(mailboxDiscoverySearch.InPlaceHoldIdentity, value);
                }
            }
            bool flag = false;

            try
            {
                flag = discoverySearchDataProvider.Mailbox.GetConfiguration().MailboxAssistants.UnifiedPolicyHold.Enabled;
            }
            catch (CannotDetermineExchangeModeException)
            {
                this.TraceInformation("Failed to load unifiedHold flight information");
            }
            if (flag)
            {
                try
                {
                    PolicyConfigProvider policyConfigProvider = PolicyConfigProviderManager <ExPolicyConfigProviderManager> .Instance.CreateForProcessingEngine(orgId);

                    if (policyConfigProvider != null)
                    {
                        ExComplianceServiceProvider          exComplianceServiceProvider = new ExComplianceServiceProvider();
                        IEnumerable <PolicyDefinitionConfig> enumerable = policyConfigProvider.FindByName <PolicyDefinitionConfig>("*");
                        if (enumerable != null && exComplianceServiceProvider != null)
                        {
                            foreach (PolicyDefinitionConfig policyDefinitionConfig in enumerable)
                            {
                                string holdId = ExMailboxComplianceItemContainer.GetHoldId(policyDefinitionConfig.Identity);
                                if (policyDefinitionConfig.Mode == Mode.Enforce && policyDefinitionConfig.Scenario == PolicyScenario.Hold)
                                {
                                    IEnumerable <PolicyRuleConfig> enumerable2 = policyConfigProvider.FindByPolicyDefinitionConfigId <PolicyRuleConfig>(policyDefinitionConfig.Identity);
                                    if (enumerable2 == null)
                                    {
                                        continue;
                                    }
                                    using (IEnumerator <PolicyRuleConfig> enumerator3 = enumerable2.GetEnumerator())
                                    {
                                        while (enumerator3.MoveNext())
                                        {
                                            PolicyRuleConfig rule = enumerator3.Current;
                                            if (dictionary.ContainsKey(holdId))
                                            {
                                                this.TraceInformation(string.Format("Hold Id contained twice.  HoldId: {0}", holdId));
                                                break;
                                            }
                                            InPlaceHoldConfiguration value2 = new InPlaceHoldConfiguration(policyDefinitionConfig, rule, exComplianceServiceProvider.GetRuleParser(), DiscoveryHoldQueryCache.Tracer);
                                            dictionary.Add(holdId, value2);
                                        }
                                        continue;
                                    }
                                }
                                this.TraceInformation(string.Format("Hold not loaded. HoldId: {0} Mode: {1} Scenario: {2}", holdId, policyDefinitionConfig.Mode.ToString(), policyDefinitionConfig.Scenario.ToString()));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    DiscoveryHoldQueryCache.Tracer.TraceDebug <Exception>((long)this.GetHashCode(), "Failed to load hold queries from PolicyConfigProvider.  Exception: {0}", ex);
                    if (logEntry != null)
                    {
                        logEntry.FailedToLoadUnifiedPolicies = ex.Message;
                    }
                }
            }
            return(dictionary);
        }