.NET Active Directory Wrapper    
Access Active Directory From Your C# or VB .Net Code
 

Getting a list of all Organization Units in Active Directory using C# or VB .Net

This method returns a collection of all organizational units (OUs) in Active Directory in the format of an LdapOUCollection.

Langauges Supported

ASP.NET, C#, VB.Net, Visual Studio 2010, Visual Sutdio 2012

Method: GetOrgUnits

Parameters:  none

Precondition

An instance of the LDAP manager must be instantiated for a valid ADDS server.

Functionality

The method is called without parameters, two things can then occur:

  1. A collection of LdapOU objects is returned.
  2. An Exception will be thrown for other errors

Example

Where LdapConnection is an instance of LdapManager

public Boolean GetOrgUnits(String ouName)
        {
            try
            {
                LdapOUCollection orgUnits = LdapConnection.GetOUs();
                return true;
            }
            catch (Exception)
            {

                throw;
            }
        }

Post Condition

The object collection is updatable.