private ArrayList GetChildDomains() { ArrayList list = new ArrayList(); if (this.crossRefDN == null) { this.LoadCrossRefAttributes(); } DirectoryEntry searchRoot = null; SearchResultCollection results = null; try { searchRoot = DirectoryEntryManager.GetDirectoryEntry(base.context, base.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.PartitionsContainer)); StringBuilder builder = new StringBuilder(15); builder.Append("(&("); builder.Append(PropertyManager.ObjectCategory); builder.Append("=crossRef)("); builder.Append(PropertyManager.SystemFlags); builder.Append(":1.2.840.113556.1.4.804:="); builder.Append(1); builder.Append(")("); builder.Append(PropertyManager.SystemFlags); builder.Append(":1.2.840.113556.1.4.804:="); builder.Append(2); builder.Append(")("); builder.Append(PropertyManager.TrustParent); builder.Append("="); builder.Append(Utils.GetEscapedFilterValue(this.crossRefDN)); builder.Append("))"); string filter = builder.ToString(); string[] propertiesToLoad = new string[] { PropertyManager.DnsRoot }; results = new ADSearcher(searchRoot, filter, propertiesToLoad, SearchScope.OneLevel).FindAll(); foreach (SearchResult result in results) { string searchResultPropertyValue = (string) PropertyManager.GetSearchResultPropertyValue(result, PropertyManager.DnsRoot); DirectoryContext context = Utils.GetNewDirectoryContext(searchResultPropertyValue, DirectoryContextType.Domain, base.context); list.Add(new Domain(context, searchResultPropertyValue)); } return list; } catch (COMException exception) { throw ExceptionHelper.GetExceptionFromCOMException(base.context, exception); } finally { if (results != null) { results.Dispose(); } if (searchRoot != null) { searchRoot.Dispose(); } } return list; }
internal static string GetAdamHostNameAndPortsFromNTDSA(DirectoryContext context, string dn) { string str = null; int num = -1; int num2 = -1; string filterValue = dn; string partialDN = GetPartialDN(dn, 1); string str4 = GetPartialDN(dn, 2); string str5 = "CN=NTDS-DSA"; DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, str4); string filter = "(|(&(" + PropertyManager.ObjectCategory + "=server)(" + PropertyManager.DistinguishedName + "=" + GetEscapedFilterValue(partialDN) + "))(&(" + PropertyManager.ObjectCategory + "=nTDSDSA)(" + PropertyManager.DistinguishedName + "=" + GetEscapedFilterValue(filterValue) + ")))"; string[] propertiesToLoad = new string[] { PropertyManager.DnsHostName, PropertyManager.MsDSPortLDAP, PropertyManager.MsDSPortSSL, PropertyManager.ObjectCategory }; SearchResultCollection results = new ADSearcher(directoryEntry, filter, propertiesToLoad, SearchScope.Subtree, true, true).FindAll(); try { if (results.Count != 2) { throw new ActiveDirectoryOperationException(Res.GetString("NoHostNameOrPortNumber", new object[] { dn })); } foreach (SearchResult result in results) { string searchResultPropertyValue = (string) PropertyManager.GetSearchResultPropertyValue(result, PropertyManager.ObjectCategory); if ((searchResultPropertyValue.Length >= str5.Length) && (Compare(searchResultPropertyValue, 0, str5.Length, str5, 0, str5.Length) == 0)) { num = (int) PropertyManager.GetSearchResultPropertyValue(result, PropertyManager.MsDSPortLDAP); num2 = (int) PropertyManager.GetSearchResultPropertyValue(result, PropertyManager.MsDSPortSSL); } else { str = (string) PropertyManager.GetSearchResultPropertyValue(result, PropertyManager.DnsHostName); } } } finally { results.Dispose(); directoryEntry.Dispose(); } if (((num == -1) || (num2 == -1)) || (str == null)) { throw new ActiveDirectoryOperationException(Res.GetString("NoHostNameOrPortNumber", new object[] { dn })); } return string.Concat(new object[] { str, ":", num, ":", num2 }); }