using System.DirectoryServices.ActiveDirectory; ... List<Domain> domains = new List<Domain>(); // flat list of domains foreach (Domain dom in Forest.GetCurrentForest().Domains) { try { domains.Add(dom); var de = dom.GetDirectoryEntry(); // Here I have de.Guid and de.Parent.Guid, so using them I can build a tree } catch () {} // for simplicity left it blank. }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)