65.9K
CodeProject is changing. Read more.
Home

Using Active Directory In ASP.NET - Enumerate Active Directory Users

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.64/5 (18 votes)

Feb 11, 2002

1 min read

viewsIcon

230231

downloadIcon

3823

An article on using DirectoryServices namespace to enumerate Active Directory Users

Sample Image - ADSI2.gif

This article is second in the series demonstrating the use of Active Directory in ASP.Net. The first article Using Active Directory In ASP.Net - Dump Schema Informations demonstrated how to get the schema information. In this article we will use the basics discussed earlier to enumerate the Active Direftory users.

This article demonstrates the use of following namespaces and classes.

  • System.DirectoryServices
  • System.DirectoryServices.DirectoryEntry
  • System.DirectoryServices.DirectorySearcher
  • System.DirectoryServices.SearchResultCollection
  • System.DirectoryServices.SearchResult
  • System.DirectoryServices.ResultPropertyCollection
  • System.DirectoryServices.PropertyValueCollection

The basics steps to implement the enumeration of Active Directory Users remain the same as discussed in the first article, Using Active Directory In ASP.NET - Dump Schema Information. The only difference is the query that is used to search for the Users.

We have added a new method, GetUsersList in ADSIUtil class. This method sets the appropriate search criteria filter to look for all the Active Directory Users. To get the list of Users, the filter is set to look for User object class.

SearchResultCollection results;
DirectorySearcher srch = new DirectorySearcher(m_obDirEntry);
srch.Filter = "(objectClass=User)";
results = srch.FindAll();

Platforms Tested

We have tested the included project on following platforms

  • Windows 2000 Adv. Server
  • Windows .NET Enterprise Server (Beta 3)

Contact Us

For any comments or suggestions, feel free to contact us at softomatix@pardesiservices.com or visit us Softomatix