internal override ADSessionSettings FromAllTenantsOrRootOrgAutoDetect(ADObjectId id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (id.DomainId == null)
            {
                ExTraceGlobals.GetConnectionTracer.TraceDebug <string>(0L, "FromAllTenantsOrRootOrgAutoDetect(): Value '{0}' passed to id parameter doesn't have DomainId initialized, falling back to RootOrg scope set", id.ToString());
                return(ADSessionSettings.FromRootOrgScopeSet());
            }
            PartitionId partitionId = id.GetPartitionId();

            if (!ADAccountPartitionLocator.IsKnownPartition(partitionId))
            {
                ExTraceGlobals.GetConnectionTracer.TraceDebug <string>(0L, "FromAllTenantsOrRootOrgAutoDetect(): Value '{0}' passed to id parameter doesn't match any known partition, falling back to RootOrg scope set", id.ToString());
                return(ADSessionSettings.FromRootOrgScopeSet());
            }
            ExTraceGlobals.GetConnectionTracer.TraceDebug <string, string>(0L, "FromAllTenantsOrRootOrgAutoDetect(): Value '{0}' passed to id parameter matches partition {1}, returning settings bound to that partition", id.ToString(), partitionId.ToString());
            if (ADSession.IsTenantIdentity(id, partitionId.ForestFQDN))
            {
                return(ADSessionSettings.FromAllTenantsObjectId(id));
            }
            if (!TopologyProvider.IsAdamTopology())
            {
                return(ADSessionSettings.FromAccountPartitionRootOrgScopeSet(id.GetPartitionId()));
            }
            return(ADSessionSettings.FromRootOrgScopeSet());
        }