Click here to Skip to main content
15,860,943 members
Articles / Programming Languages / C#
Tip/Trick

Dynamically Browse Active Directory Objects

Rate me:
Please Sign up or sign in to vote.
4.25/5 (16 votes)
1 Feb 2004CPOL1 min read 139.8K   3.7K   48   12
A simple program which lets you browse containers of your Active Directory
Image 1

Introduction

This tip shows you how to browse your Active Directory using the Simple AD Browser. The Windows Forms project is quite simple. It contains a treeview control for navigating and expanding AD objects and a listview object showing the selected object data. A connection dialog allows you to initially connect to an AD or change connection to another AD. The solution consists of two projects:

  1. the above mentioned Windows Forms project
  2. a class library which handles Active Directory communication

The class library for AD communication, which is called "Simple AD Browser Helpers.dll", has a reference to ADSI (http://msdn.microsoft.com/en-us/library/windows/desktop/aa772170%28v=vs.85%29.aspx).

The ADSI SDK is needed since we need the interfaces IADsPropertyList and IADsPropertyEntry for making sure that Active Directory types, which are unknown to the .NET Framework, are displayed properly.

If you are having trouble compiling the class library "Simple AD Browser Helpers.dll", because the reference "Interop.ActiveDs" or "ActiveDs" was not found, please do the following steps:

  1. Select "Solution Explorer" in Visual Studio
  2. Navigate to & expand the project "Simple AD Browser Helpers"
  3. Right click on references and choose "Add Reference..."
  4. Choose "Browse"
  5. Go to your Windows directory, e.g., C:\Windows\SysWOW64
  6. Select the file "activeds.tlb"
  7. Hit "OK"

Revisions

  • Initial release 02.02.2004
  • Code rework 05.01.2014 (cleaned up code and added class library for AD communication, added ADSI type conversions)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Ciber Germany
Germany Germany
Sebastian is an consultant who works at Ciber Germany. He engineers software in various languages but loves C# and C. In his past projects he did CAD SAP integration, SharePoint, software design with UML and coordinating fellow developers.

In his free time he likes to build&fly R/C airplanes and take his mountain bike out for a ride.

Comments and Discussions

 
Questionquery regarding code Pin
Vamshi Mekala13-Feb-13 19:56
Vamshi Mekala13-Feb-13 19:56 
GeneralMy vote of 4 Pin
SavindraSingh30-Jan-13 2:56
SavindraSingh30-Jan-13 2:56 
Generalexcellent Pin
sypatil28-Jul-09 8:04
sypatil28-Jul-09 8:04 
Questionin web application Pin
omer nauman16-Jul-08 23:35
omer nauman16-Jul-08 23:35 
AnswerRe: in web application Pin
Sebastian Sosna17-Jul-08 4:24
Sebastian Sosna17-Jul-08 4:24 
Generalawesome. Pin
omer nauman16-Jul-08 1:26
omer nauman16-Jul-08 1:26 
Question? Can I access LDAP of Solaris environment from my Windows Pin
Suranjan Nandi9-Mar-06 3:17
Suranjan Nandi9-Mar-06 3:17 
AnswerRe: ? Can I access LDAP of Solaris environment from my Windows Pin
Sebastian Sosna9-Mar-06 4:14
Sebastian Sosna9-Mar-06 4:14 
GeneralLooks wonderful... Pin
Michael D Bray4-Feb-04 4:33
Michael D Bray4-Feb-04 4:33 
I did something very similar (albeit without a treeview.) Just from looking at your screen shot, I have one suggestion - print the contents of byte arrays instead of just 'System.Byte[]'. I'll be comparing our versions and probably learning a bit more about AD shortly. Smile | :)

-mdb
GeneralRe: Looks wonderful... Pin
Sebastian Sosna4-Feb-04 22:10
Sebastian Sosna4-Feb-04 22:10 
GeneralRe: Looks wonderful... Pin
Anonymous23-Aug-04 21:44
Anonymous23-Aug-04 21:44 
GeneralRe: Looks wonderful... Pin
Sebastian Sosna25-Aug-04 2:08
Sebastian Sosna25-Aug-04 2:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.