Creating a Group in Active Directory using C# or VB .Net
It is possible to create a new Active Directory group using the LDAPManager
Method: CreateGroup
Parameters: (string) Group name, (string) Group
description, (overload) (string) Group Type
Programming Languages Supported
ASP.NET, C#, VB.Net, Visual Studio 2010, Visual Sutdio 2008
Precondition
An instance of the LDAP manager must be instantiated for a valid Active Directory server
and must be logged in.
Functionality
The method is called passing the Group name as a string. Three
things can then occur:
- If the Group is created and the method returns a Group object.
- If the Group name already exists the method throws an error.
- An Exception will be thrown for other errors
Example
Where LdapConnection is an instance of LdapManager
public Boolean CreateGroup(String group, String groupDescription)
{
/* There is an overload third parameter of Group type*/
try
{
LdapGroup ldapGroup = LdapConnection.CreateGroup(group, groupDescription);
return true;
}
catch (Exception)
{
throw;
}
}
Post Condition
On success the method returns a valid group object.
|