Introduction
Ever wondered how to write a simple Active Directory Browser? Well, then look at my example code here. Its quite simple and straightforward. I am utilizing System.DirectoryServices to connect to AD and enumerate objects.
Of course, this is a simple example which doesn't include threading to make the user interface respond faster. But it will give you an idea of how to connect to AD and do some simple browsing.
Code Basics
To connect to Active Directory is quite simple:
DirectoryEntry rootDSE = new
DirectoryEntry("LDAP<A href="ldap:
DirectoryEntry root = new DirectoryEntry("LDAP://" +
(string)rootDSE.Properties["defaultNamingContext"].Value);
The property defaultNamingContext contains the domain name in format: "dc=test,dc=com" (for domain name "test.com") which we use to connect to the test.com domain.