Creating a new Active Directory User Account using C# or VB .Net
Creating a new Active Directory user is very simple using the LDAPManager.
Method: CreateUser
Parameters: (string) Username, (string) firstname,
(string) initial, (string) lastname, (string) fullname, (string) password
(optional: (string) Organizational Unit, (string) Email)
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 ADDS server
and must be logged in.
Functionality
The method is called passing the parameters. Two things can then occur:
- The user is created and the method returns an user object
- An Exception will be thrown for other errors
Example
Where LdapConnection is an instance of LdapManager
public LdapUser CreateUser(String username, String firstname, String initial, String lastname, String fullname, String password)
{
/* Has an overload to include ou and email*/
try
{
return LdapConnection.CreateUser(username, firstname, initial, lastname, fullname, password);
}
catch (Exception)
{
throw;
}
}
Post Condition
The method returns an LDAPUser object
|