Reader Level:
Articles

Listing Active Directory Users

By John O Donnell on April 06, 2003
The attached source code shows you how to list an active directory users in .NET using C#.
  • 0
  • 0
  • 91507
Download Files:
 

As always when you do anything with the Active Directory in Windows 2000 if you do not know much about it stay clear or ask a domain administrator.

While many companies use the Active Directory not many use it to store all employee info. Many companies just use it to store the employees username and email. Of course Active Directory could in effect become your employee directory if you add all the other information like phone numbers.

This code simply outputs all the information for each user like name, title and phone numbers. A later article will expand on it and create a real employee search tool. Dont forget to reference System.DirectoryServices.dll.

This code is non destructive in that it only reads data from the active directory but make sure you know what you are doing before using it.

05/22/03 - Update I have now modified this code and compiled under the RTM of Visual Studio.Net 2003. The updated code uses the Contains method of the DirectoryEntry class. Using this method allows me to check for the presence of a property before trying to access it and possible causing an exception. Also I am now using an objectcategory of person which should give you more relevant results.

John O Donnell

John O’Donnell is a former Microsoft UK employee and is an MCSE. Currently John works in Chicago for MAS Consulting (www.mcas.com) as a Senior Technical Consultant. He is available for C# contract work across the USA .

COMMENT USING

Trending up