// Token: 0x060072B9 RID: 29369 RVA: 0x0017BC24 File Offset: 0x00179E24
        internal override IThrottlingPolicy InternalLookup()
        {
            ExchangeConfigurationUnit cu = null;
            ADOperationResult         adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                PartitionId partitionIdByAcceptedDomainName = ADAccountPartitionLocator.GetPartitionIdByAcceptedDomainName(this.principal.DelegatedOrganization);
                if (partitionIdByAcceptedDomainName != null)
                {
                    ADSessionSettings sessionSettings = ADSessionSettings.FromAllTenantsPartitionId(partitionIdByAcceptedDomainName);
                    ITenantConfigurationSession tenantConfigurationSession           = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, sessionSettings, 86, "InternalLookup", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\throttling\\DelegatedPrincipalBudgetKey.cs");
                    tenantConfigurationSession.SessionSettings.IsSharedConfigChecked = true;
                    cu = tenantConfigurationSession.GetExchangeConfigurationUnitByNameOrAcceptedDomain(this.principal.DelegatedOrganization);
                }
                if (cu == null)
                {
                    throw new CannotResolveTenantNameException(DirectoryStrings.CannotResolveTenantNameByAcceptedDomain(this.principal.DelegatedOrganization));
                }
            });

            if (!adoperationResult.Succeeded)
            {
                ExTraceGlobals.ClientThrottlingTracer.TraceError <string, string, Exception>((long)this.GetHashCode(), "[DelegatedPrincipalBudgetKey.Lookup] Failed to find Delegated Organization: '{0}' for user '{1}', using global throttling policy.  Exception: '{2}'", this.principal.DelegatedOrganization, this.principal.UserId, adoperationResult.Exception);
                return(ThrottlingPolicyCache.Singleton.GetGlobalThrottlingPolicy());
            }
            OrganizationId orgId = cu.OrganizationId;

            if (cu.SupportedSharedConfigurations.Count > 0)
            {
                SharedConfiguration sharedConfig = null;
                adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
                {
                    sharedConfig = SharedConfiguration.GetSharedConfiguration(cu.OrganizationId);
                });
                if (!adoperationResult.Succeeded)
                {
                    ExTraceGlobals.ClientThrottlingTracer.TraceError <OrganizationId, Exception>((long)this.GetHashCode(), "[DelegatedPrincipalBudgetKey.Lookup] Failed to get Shared Configuration Organization: '{0}', using global throttling policy.  Exception: '{1}'", cu.OrganizationId, adoperationResult.Exception);
                    return(ThrottlingPolicyCache.Singleton.GetGlobalThrottlingPolicy());
                }
                if (sharedConfig != null)
                {
                    orgId = sharedConfig.SharedConfigId;
                }
            }
            return(base.ADRetryLookup(delegate
            {
                ADSessionSettings sessionSettings = ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(orgId);
                IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 149, "InternalLookup", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\throttling\\DelegatedPrincipalBudgetKey.cs");
                tenantOrTopologyConfigurationSession.SessionSettings.IsSharedConfigChecked = true;
                ThrottlingPolicy organizationThrottlingPolicy = tenantOrTopologyConfigurationSession.GetOrganizationThrottlingPolicy(orgId, false);
                if (organizationThrottlingPolicy == null)
                {
                    ExTraceGlobals.ClientThrottlingTracer.TraceError <string, string>((long)this.GetHashCode(), "[DelegatedPrincipalBudgetKey.Lookup] Failed to find Default Throttling Policy for '{0}\\{1}', using global throttling policy", this.principal.DelegatedOrganization, this.principal.UserId);
                    return ThrottlingPolicyCache.Singleton.GetGlobalThrottlingPolicy();
                }
                return organizationThrottlingPolicy.GetEffectiveThrottlingPolicy(true);
            }));
        }
        private static CachableThrottlingPolicyItem ResolveOrganizationThrottlingPolicy(object obj, OrganizationId organizationId)
        {
            SharedConfiguration sharedConfiguration = SharedConfiguration.GetSharedConfiguration(organizationId);

            if (sharedConfiguration != null)
            {
                organizationId = sharedConfiguration.SharedConfigId;
            }
            ThrottlingPolicy throttlingPolicy = ThrottlingPolicyCache.ReadThrottlingPolicyFromAD(ThrottlingPolicyCache.GetSession(organizationId), organizationId, (IConfigurationSession session1, object id) => session1.GetOrganizationThrottlingPolicy((OrganizationId)id));

            return(new CachableThrottlingPolicyItem((throttlingPolicy == null) ? ThrottlingPolicyCache.Singleton.GetGlobalThrottlingPolicy() : throttlingPolicy.GetEffectiveThrottlingPolicy(true)));
        }
        // Token: 0x06001173 RID: 4467 RVA: 0x00054090 File Offset: 0x00052290
        public static IConfigurationSession CreateScopedToSharedConfigADSession(OrganizationId orgId)
        {
            ADSessionSettings adsessionSettings = null;

            if (SharedConfiguration.IsDehydratedConfiguration(orgId) || SharedConfiguration.IsSharedConfiguration(orgId))
            {
                SharedConfiguration sharedConfiguration = SharedConfiguration.GetSharedConfiguration(orgId);
                if (sharedConfiguration != null)
                {
                    adsessionSettings = sharedConfiguration.GetSharedConfigurationSessionSettings();
                }
            }
            if (adsessionSettings == null)
            {
                adsessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), orgId, null, false);
            }
            return(DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, adsessionSettings, 366, "CreateScopedToSharedConfigADSession", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SharedConfiguration.cs"));
        }