ARTICLE

Listing Active Directory Users

Posted by John O Donnell Articles | Active Directory C# April 06, 2003
The attached source code shows you how to list an active directory users in .NET using C#.
Reader Level:
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.

Login to add your contents and source code to this article
post comment
     

If you want to get a list of all the properties on the AD then update the code to do this: foreach (String keyName in de.Properties.PropertyNames) { Console.WriteLine(keyName + ": " + de.Properties[keyName].Value.ToString()); }

Posted by Steven Newson Apr 09, 2009

"The attached source code shows you how " Hi you said Where is the source code?

Posted by awsok Dec 14, 2007
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts