Active Directory Programming Examples

This page contains example 1 of VB Programming for Active Directory.

Example 1
Active Directory UserInfo

For this first example Iíve written a short and simple program that accepts a few characters of a Name (First or Last / First and Last) or login ID. When the search button is click the Active Directory (AD) is searched for matches. All matches are displayed in a listbox where the operator can then select them one at a time.(with the mouse pointer or keyboard arrow keys). As each listitem is selected the User/Contact attribute fields are populated with the values for the item selected.

The program uses the credentials of the current user and assumes the program is running on a domain member workstation or server. It only searches the domain that the user is logged in to. As far as I know all of the attributes Iím accessing are native to the default Windows 2003 AD schema with Exchange 2007 installed. No additional configuration should be required. I went crazy with the commenting, but if you have any questions you may send them to me at

Some of the stuff I had a hard time finding out how to do (That are in this program) include.

In future installments I intend to show you how to sort the listview data by clicking its column and how to write to all of these fields. The ATGM program shows a lot of how to work with groups but it does have some dangerous features.
Oh, one other thing. Youíll have to add a reference to System.DirectoryServices and System.DirectoryServices.AccountManagement in most versions of Visual Studio you right click on the project name (In the Solution Explorer) itís on the far right of the screen. Select Add Referance, when the Add Reference box opens select the .NET tab scroll down till you see the reference you wish to Add, hold the Ctrl key and select System.DirectoryServices.AccountManagement and System.DirectoryServices then click OK.
View Example 1 Code in it's own TAB

Add reference Thumbnail                   Userinfo Thumbnail