private void GetRootDSEChildItemsOrNames(bool namesOnly, bool recurse, ReturnContainers returnContainers, string filter) { Collection<string> strs; int sizeLimit; IADOPathNode ldapFilterADOPathNode; this.Trace(DebugLogLevel.Verbose, "Entering GetRootDSEChildItemsOrNames"); this.Trace(DebugLogLevel.Info, string.Format("GetRootDSEChildItemsOrNames: namesOnly = {0}", namesOnly)); this.Trace(DebugLogLevel.Info, string.Format("GetRootDSEChildItemsOrNames: recurse = {0}", recurse)); this.Trace(DebugLogLevel.Info, string.Format("GetRootDSEChildItemsOrNames: returnContainers = {0}", returnContainers)); this.Trace(DebugLogLevel.Info, string.Format("GetRootDSEChildItemsOrNames: filter = {0}", filter)); ADProviderSearchParameters dynamicParameters = base.DynamicParameters as ADProviderSearchParameters; ADSessionInfo sessionInfo = this.GetSessionInfo(dynamicParameters, base.Credential, this.ExtendedDriveInfo); if (this.ValidateDynamicParameters("", dynamicParameters, sessionInfo)) { ADObjectSearcher aDObjectSearcher = null; ADPathFormat formatType = this.GetFormatType(dynamicParameters, this.ExtendedDriveInfo); using (aDObjectSearcher) { try { int num = 0; if (dynamicParameters != null) { sizeLimit = dynamicParameters.SizeLimit; } else { sizeLimit = 0; } int num1 = sizeLimit; ADRootDSE rootDSE = this.GetRootDSE(sessionInfo); sessionInfo.ServerType = this.GetServerType(rootDSE); if (!recurse) { if (dynamicParameters == null || dynamicParameters.Properties == null) { strs = new Collection<string>(); } else { strs = new Collection<string>(dynamicParameters.Properties); } HashSet<ADObject> allHostedNamingContexts = this.GetAllHostedNamingContexts(sessionInfo, rootDSE, this.ExtendedDriveInfo, strs); this.Trace(DebugLogLevel.Verbose, "GetRootDSEChildItemsOrNames: Clearing rootdse child cache."); this.ExtendedDriveInfo.NamingContexts.Clear(); HashSet<ADObject>.Enumerator enumerator = allHostedNamingContexts.GetEnumerator(); try { do { Label2: if (!enumerator.MoveNext()) { break; } ADObject current = enumerator.Current; string distinguishedName = null; if (formatType != ADPathFormat.Canonical) { distinguishedName = current.DistinguishedName; } else { if (!current.Contains("canonicalName")) { this.Trace(DebugLogLevel.Warning, string.Format("NewDrive: Unable to read canonical name for naming context {0}, skipping..", current.DistinguishedName)); goto Label2; } else { distinguishedName = (string)current["canonicalName"].Value; } } this.ExtendedDriveInfo.NamingContexts.Add(distinguishedName); this.Trace(DebugLogLevel.Verbose, string.Format("GetRootDSEChildItemsOrNames: Adding path to rootdse child cache: {0}", distinguishedName)); if (!namesOnly) { this.WriteADObject(current, sessionInfo, dynamicParameters, this.ExtendedDriveInfo); } else { this.WriteADRootDSEChildName(current, dynamicParameters, this.ExtendedDriveInfo); } num++; } while (num != num1); } finally { enumerator.Dispose(); } } else { if (this.IsServerGlobalCatalog(sessionInfo, rootDSE, dynamicParameters, this.ExtendedDriveInfo)) { ADProvider aDProvider = this; string str = ""; int num2 = 2; if (filter != null) { ldapFilterADOPathNode = new LdapFilterADOPathNode(filter); } else { ldapFilterADOPathNode = null; } aDObjectSearcher = aDProvider.GetADObjectSearcher(str, (ADSearchScope)num2, ldapFilterADOPathNode, dynamicParameters, base.Credential, this.ExtendedDriveInfo); IEnumerator<ADObject> enumerator1 = aDObjectSearcher.FindAll().GetEnumerator(); using (enumerator1) { do { Label3: if (!enumerator1.MoveNext()) { break; } ADObject aDObject = enumerator1.Current; if (formatType != ADPathFormat.Canonical || aDObject.Contains("canonicalName")) { if (!namesOnly) { this.WriteADObject(aDObject, sessionInfo, dynamicParameters, this.ExtendedDriveInfo); } else { this.WriteADRootDSEChildName(aDObject, dynamicParameters, this.ExtendedDriveInfo); } num++; } else { this.Trace(DebugLogLevel.Warning, string.Format("GetRootDSEChildItemsOrNames: Unable to read canonical name for object {0}, skipping..", aDObject.DistinguishedName)); goto Label3; } } while (num != num1); } } else { base.WriteError(ADUtilities.GetErrorRecord(new NotSupportedException(StringResources.ADProviderOperationNotSupportedForRootDSEUnlessGC), "NotSupported", "")); this.Trace(DebugLogLevel.Error, "Leaving MoveItem: NotSupportedException: recursive search requested on non-GC rootdse."); return; } } } catch (ADException aDException1) { ADException aDException = aDException1; base.WriteError(ADUtilities.GetErrorRecord(aDException, "ADProvider:GetRootDSEChildItemsOrNames:ADError", "")); this.Trace(DebugLogLevel.Error, "Leaving GetRootDSEChildItemsOrNames: ADException: AD error"); return; } catch (AuthenticationException authenticationException1) { AuthenticationException authenticationException = authenticationException1; base.WriteError(ADUtilities.GetErrorRecord(authenticationException, "ADProvider:GetRootDSEChildItemsOrNames:InvalidCredentials", "")); this.Trace(DebugLogLevel.Error, "Leaving GetRootDSEChildItemsOrNames: ADException: invalid credentials"); return; } this.Trace(DebugLogLevel.Verbose, "Leaving GetRootDSEChildItemsOrNames"); return; } return; } else { this.Trace(DebugLogLevel.Verbose, "Leaving GetRootDSEChildItemsOrNames : ValidateDynamicParameters returned false"); return; } }
private void GetChildItemsOrNames(string path, ADSearchScope scope, bool namesOnly, ReturnContainers returnContainers, string filter) { IADOPathNode ldapFilterADOPathNode; int sizeLimit; this.Trace(DebugLogLevel.Verbose, "Entering GetChildItemsOrNames"); path = this.ValidateAndNormalizePath(path); this.Trace(DebugLogLevel.Info, string.Format("GetChildItemsOrNames: path = {0}", path)); this.Trace(DebugLogLevel.Info, string.Format("GetChildItemsOrNames: scope = {0}", scope)); this.Trace(DebugLogLevel.Info, string.Format("GetChildItemsOrNames: namesOnly = {0}", namesOnly)); this.Trace(DebugLogLevel.Info, string.Format("GetChildItemsOrNames: returnContainers = {0}", returnContainers)); this.Trace(DebugLogLevel.Info, string.Format("GetChildItemsOrNames: filter = {0}", filter)); ADProviderSearchParameters dynamicParameters = base.DynamicParameters as ADProviderSearchParameters; ADSessionInfo sessionInfo = this.GetSessionInfo(dynamicParameters, base.Credential, this.ExtendedDriveInfo); if (this.ValidateDynamicParameters(path, dynamicParameters, sessionInfo)) { ADPathFormat formatType = this.GetFormatType(dynamicParameters, this.ExtendedDriveInfo); ADProvider aDProvider = this; string str = path; ADSearchScope aDSearchScope = scope; if (filter != null) { ldapFilterADOPathNode = new LdapFilterADOPathNode(filter); } else { ldapFilterADOPathNode = null; } ADObjectSearcher aDObjectSearcher = aDProvider.GetADObjectSearcher(str, aDSearchScope, ldapFilterADOPathNode, dynamicParameters, base.Credential, this.ExtendedDriveInfo); using (aDObjectSearcher) { try { int num = 0; if (dynamicParameters != null) { sizeLimit = dynamicParameters.SizeLimit; } else { sizeLimit = 0; } int num1 = sizeLimit; sessionInfo.ServerType = this.GetServerType(sessionInfo); IEnumerator<ADObject> enumerator = aDObjectSearcher.FindAll().GetEnumerator(); using (enumerator) { do { Label1: if (!enumerator.MoveNext()) { break; } ADObject current = enumerator.Current; if (formatType != ADPathFormat.Canonical || current.Contains("canonicalName")) { if (!namesOnly) { this.WriteADObject(current, sessionInfo, dynamicParameters, this.ExtendedDriveInfo); } else { this.WriteADObjectName(current, dynamicParameters, this.ExtendedDriveInfo); } num++; } else { this.Trace(DebugLogLevel.Warning, string.Format("GetChildItemsOrNames: Unable to read canonical name for object {0}, skipping..", current.DistinguishedName)); goto Label1; } } while (num != num1); } } catch (ADException aDException1) { ADException aDException = aDException1; base.WriteError(ADUtilities.GetErrorRecord(aDException, "ADProvider:GetChildItemsOrNames:ADError", path)); this.Trace(DebugLogLevel.Error, "Leaving GetChildItemsOrNames: ADException: AD error"); return; } catch (AuthenticationException authenticationException1) { AuthenticationException authenticationException = authenticationException1; base.WriteError(ADUtilities.GetErrorRecord(authenticationException, "ADProvider:GetChildItemsOrNames:InvalidCredentials", path)); this.Trace(DebugLogLevel.Error, "Leaving GetChildItemsOrNames: ADException: invalid credentials"); return; } } this.Trace(DebugLogLevel.Verbose, "Leaving GetChildItemsOrNames"); return; } else { this.Trace(DebugLogLevel.Verbose, "Leaving GetChildItemsOrNames : ValidateDynamicParameters returned false"); return; } }