SIGN UP MEMBER LOGIN:    
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
share 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
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Nevron Gauge for SharePoint
Become a Sponsor