In my application I need to get Active Directory forest and list the domains hierarchy.
I was given the Active Directory account that has necessary permissions. However my development computer is NOT on the domain and can not be added to the domain.
Here is the code that I am using to get the forest and access the root domain:
// I also tried to add a Global Catalog port: 192.168.2.11:3268, no success
DirectoryContext dc = new DirectoryContext(
DirectoryContextType.Forest, "192.168.2.11", “Login1”, “pass1”);
Forest f = Forest.GetForest(dc);
Console.WriteLine("Forest name: " + f.Name);
Console.WriteLine("Root domain: " + f.RootDomain);
How do I modify it to discover domains in case I run it on a computer that is not on a domain?