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()); }
// Token: 0x06000316 RID: 790 RVA: 0x00010B78 File Offset: 0x0000ED78 public static bool IsKnownPartition(PartitionId partitionId) { if (TopologyProvider.IsAdamTopology()) { return(true); } if (!Globals.IsMicrosoftHostedOnly && partitionId.PartitionObjectId == null) { return(false); } ADAccountPartitionLocator.LoadPartitionCacheIfNecessary(); return(partitionId.IsLocalForestPartition() || ADAccountPartitionLocator.partitionsFQDNToGuid.ContainsKey(partitionId.ForestFQDN)); }
internal virtual ADSessionSettings FromRootOrgBootStrapSession(ADObjectId configNC) { if (configNC == null) { throw new ArgumentNullException("configNC"); } return(ADSessionSettings.SessionSettingsFactory.CreateADSessionSettings(ADSessionSettings.SessionSettingsFactory.GlobalScopeSet, configNC, OrganizationId.ForestWideOrgId, null, ConfigScopes.RootOrg, TopologyProvider.IsAdamTopology() ? PartitionId.LocalForest : configNC.GetPartitionId())); }
protected SearchResultEntryCollection GetNextResultCollection(Type controlType, out DirectoryControl responseControl) { SearchRequest searchRequest = new SearchRequest(null, this.ldapFilter, (SearchScope)this.scope, this.ldapAttributes); searchRequest.Controls.AddRange(this.directoryControls); searchRequest.SizeLimit = this.SizeLimit; if (this.session.ServerTimeout != null) { searchRequest.TimeLimit = this.session.ServerTimeout.Value; } SearchResponse searchResponse = null; responseControl = null; RetryManager retryManager = new RetryManager(); ADObjectId adobjectId = this.rootId; bool flag = !this.session.SessionSettings.IncludeSoftDeletedObjects && !this.session.SessionSettings.IncludeInactiveMailbox && this.session.EnforceContainerizedScoping; for (;;) { PooledLdapConnection readConnection = this.session.GetReadConnection(this.preferredServerName, null, ref adobjectId, this.ScopeDeterminingObject); Guid serviceProviderRequestId = Guid.Empty; try { try { if (this.useNullRoot) { searchRequest.DistinguishedName = null; } else { searchRequest.DistinguishedName = adobjectId.ToDNString(); if (flag && searchRequest.Scope == SearchScope.Subtree) { ADObjectId domainId = adobjectId.DomainId; if (domainId != null) { ADObjectId childId = domainId.GetChildId("OU", "Microsoft Exchange Hosted Organizations"); ADObjectId parent = adobjectId.Parent; if (childId != null && parent != null && ADObjectId.Equals(childId, parent)) { searchRequest.Scope = SearchScope.OneLevel; } } } } if (TopologyProvider.IsAdamTopology() && string.IsNullOrEmpty(searchRequest.DistinguishedName)) { searchRequest.Controls.Add(new SearchOptionsControl(SearchOption.PhantomRoot)); } ExTraceGlobals.ADFindTracer.TraceDebug((long)this.GetHashCode(), "ADGenericReader::GetNextResultCollection({0}) using {1} - LDAP search from {2}, scope {3}, filter {4}", new object[] { controlType.Name, readConnection.ADServerInfo.FqdnPlusPort, searchRequest.DistinguishedName, (int)searchRequest.Scope, searchRequest.Filter }); serviceProviderRequestId = Trace.TraceCasStart(CasTraceEventType.ActiveDirectory); searchResponse = (SearchResponse)readConnection.SendRequest(searchRequest, LdapOperation.Search, null, this.session.ActivityScope, this.session.CallerInfo); this.preferredServerName = readConnection.ServerName; this.session.UpdateServerSettings(readConnection); break; } catch (DirectoryException de) { if (this.customExceptionHandler != null) { this.customExceptionHandler(de); } if (readConnection.IsResultCode(de, ResultCode.NoSuchObject)) { ExTraceGlobals.ADFindTracer.TraceWarning <string, object>((long)this.GetHashCode(), "NoSuchObject caught when searching from {0} with filter {1}", searchRequest.DistinguishedName, searchRequest.Filter); return(null); } if (readConnection.IsResultCode(de, ResultCode.VirtualListViewError) && this.lcid != LcidMapper.DefaultLcid) { ExTraceGlobals.ADFindTracer.TraceWarning <int, int>((long)this.GetHashCode(), "VirtualListView error caught when performing a VLV lookup using LCID 0x{0:X}. Falling back to US English 0x{1:X}", this.lcid, LcidMapper.DefaultLcid); this.RefreshSortControlWithDefaultLCID(searchRequest); } else { retryManager.Tried(readConnection.ServerName); this.session.AnalyzeDirectoryError(readConnection, searchRequest, de, retryManager.TotalRetries, retryManager[readConnection.ServerName]); } } continue; } finally { bool isSnapshotInProgress = PerformanceContext.Current.IsSnapshotInProgress; bool flag2 = ETWTrace.ShouldTraceCasStop(serviceProviderRequestId); if (isSnapshotInProgress || flag2) { string text = string.Format(CultureInfo.InvariantCulture, "scope: {0}, filter: {1}", new object[] { searchRequest.Scope, searchRequest.Filter }); if (isSnapshotInProgress) { PerformanceContext.Current.AppendToOperations(text); } if (flag2) { Trace.TraceCasStop(CasTraceEventType.ActiveDirectory, serviceProviderRequestId, 0, 0, readConnection.ADServerInfo.FqdnPlusPort, searchRequest.DistinguishedName, "ADGenericReader::GetNextResultCollection", text, string.Empty); } } readConnection.ReturnToPool(); } break; } responseControl = this.FindControlInCollection(searchResponse.Controls, controlType); return(searchResponse.Entries); }
protected void PopulateDomainNamingContexts(string partitionFqdn) { TopologyProvider.EnforceNonEmptyPartition(partitionFqdn); ADServerInfo defaultServerInfo = this.GetDefaultServerInfo(partitionFqdn); if (string.IsNullOrEmpty(defaultServerInfo.WritableNC) || string.IsNullOrEmpty(defaultServerInfo.RootDomainNC)) { PooledLdapConnection pooledLdapConnection = LdapConnectionPool.CreateOneTimeConnection(null, defaultServerInfo, LocatorFlags.None); try { if (string.IsNullOrEmpty(pooledLdapConnection.ADServerInfo.WritableNC) && !TopologyProvider.IsAdamTopology()) { this.LogRootDSEReadFailureAndThrow("domainNamingContext", defaultServerInfo.FqdnPlusPort); } this.domainNCs[partitionFqdn] = ADObjectId.ParseExtendedDN(pooledLdapConnection.ADServerInfo.WritableNC); if (string.IsNullOrEmpty(pooledLdapConnection.ADServerInfo.RootDomainNC) && !TopologyProvider.IsAdamTopology()) { this.LogRootDSEReadFailureAndThrow("rootDomainNamingContext", defaultServerInfo.FqdnPlusPort); } this.rootDomainNCs[partitionFqdn] = ADObjectId.ParseExtendedDN(pooledLdapConnection.ADServerInfo.RootDomainNC); return; } finally { pooledLdapConnection.ReturnToPool(); } } this.domainNCs[partitionFqdn] = ADObjectId.ParseExtendedDN(defaultServerInfo.WritableNC); this.rootDomainNCs[partitionFqdn] = ADObjectId.ParseExtendedDN(defaultServerInfo.RootDomainNC); }