Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Simple Active Directory Browser

0.00/5 (No votes)
16 Dec 2003 1  
A simple Active Directory Browser for beginners.

Sample Image - ActiveDirectoryBrowser.jpg

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.

I also used my listview column sorter class, which is available here.

Code Basics

To connect to Active Directory is quite simple:

// connect to active directory 

DirectoryEntry rootDSE = new 
  DirectoryEntry("LDAP<A href="ldap://rootDSE/">://rootDSE/</A>"); 

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.

History

  • 2003-11-04 - First edition, more updates will come later.
  • 2003-11-13 - Dominic found a bug. I uploaded a new example project that fixes the bug.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here