private List <string> GetParentDomainPaths(DirectoryEntry directoryEntry, List <string> parentPaths) { PropertyValueCollection memberValueCollection = directoryEntry.Properties[ActiveDirectoryProperties.MemberOf]; if (memberValueCollection != null) { IEnumerator memberEnumerator = memberValueCollection.GetEnumerator(); while (memberEnumerator.MoveNext()) { if (memberEnumerator.Current != null) { string currentValue = AdDomainPathHandler.Escape(memberEnumerator.Current.ToString()); if (!parentPaths.Contains(currentValue)) { parentPaths.Add(currentValue); string fullDomainPath = domainPath.GetPathWithProtocol() + "/" + currentValue; using (var entry = new DirectoryEntry(fullDomainPath)) { GetParentDomainPaths(entry, parentPaths); } } } } } return(parentPaths); }
private static List <string> GetChildDomainPaths(DirectoryEntry directoryEntry) { var memberPaths = new List <string>(); PropertyValueCollection memberValueCollection = directoryEntry.Properties[ActiveDirectoryProperties.Member]; if (memberValueCollection != null) { IEnumerator memberEnumerator = memberValueCollection.GetEnumerator(); while (memberEnumerator.MoveNext()) { if (memberEnumerator.Current != null) { memberPaths.Add(AdDomainPathHandler.Escape(memberEnumerator.Current.ToString())); } } } return(memberPaths); }