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

Creating an Organizational Unit in Active Directory using C# or VB .Net

It is possible to create a new ADDS Organization Unit using the LDAPManager

Method: CreateOU

Parameters:  (string) Organization Unit

Programming Languages Supported

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

Precondition

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

Functionality

The method is called passing the Organization Unit as a string. Three things can then occur:

  1. If the Organization Unit is created and the method a valid Organization Unit object.
  2. If the Organization Unit exists the method throws an error.
  3. An Exception will be thrown for other errors

Example

Where LdapConnection is an instance of LdapManager

public Boolean CreateOU(String orgUnit)
        {
            try
            {
                LdapOU ldapGroup = LdapConnection.CreateOU(orgUnit);
                return true;
            }
            catch (Exception)
            {
                throw;
            }
        }

Post Condition

It should be noted that there is no residual connection to the authenticated User Name, this method does not result in any "Login" context.