Note: If you are using .NET Framework 3.5 or better, check out this post for querying the Active Directory!Working with the Active Directory is one of the things that every .NET or ASP.NET will face in his career. Most of the time you need information from the Active Directory. Editing, inserting or removing objects from a .NET (web)application is very rare, mostly because a System Administrator is managing the Active Directory.
Let me show you how to get started on getting information out of the Active Directory.
The basicsEverything you need to work with the Active Directory lives in the
System.DirectoryServices namespace.
The most important classes you will need are:
Directory SearcherDirectory EntrySearch ResultSo I advice you reading through the documentation of these classes.
Getting familiar with LDAP queriesI strongly advice you to try
LDP.EXELdp.exe is a Windows 2000 Support Tools utility you can use to perform Lightweight Directory Access Protocol (LDAP) searches against the Active Directory for specific information given search criteria. This also allows administrators to query data that would otherwise not be visible through the Administrative tools included in the product. All data that is returned in LDP queries, however, is subject to security permissions.
.gif)
This tool will help you understand LDAP queries. Go through
this article in the Microsoft Knowledge Base to get started.