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

Retrieving List of Active Directory Groups using C# or VB .Net

This method returns groups and optionally takes a group as a parameter

Method: GetGroups

Parameters:  (Optional) (string) Group

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 be logged in.

Functionality

The method is called optionally passing a group as a string. Two things can then occur:

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

Example

Where LdapConnection is an instance of LdapManager

        public LdapGroupCollection GetGroups(String group)
        {
            /* There is an overload for GroupName*/
            try
            {
                return LdapConnection.GetGroups();
            }
            catch (Exception)
            {

                throw;
            }
        }

Post Condition

The collection of groups is updatable and the connection remains open.