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

.NET Active Directory Wrapper Lite

Download .Net Active Directory Wrapper Lite.Net Active Directory Lite is a free package of two Visual Studio solutions (.sln) that includes all the source code to calling multiple Active Directory function and a complete sample application that demonstrates the functionality of the wrapper. Both solutions are written in C# and are combatible with both .Net Framework 1.1, 2.0 and 3.0.

The first Visual Studio Solution is a Class Library application. The output binary files contain one dll that facilitates calling of Active Directory functions from your code. Please see below for sample usage.

The second Visual Studio Solution is a Windows application. This application uses the output DLL that is generated by the Class Library application and demonstrates how the component should be used.

Configuration of the component is easy. Four parameters need to be set in code: The Active Directory domain that needs to be accessed, the username of the account that has permissions to execute Active Directory functions and the password for that account and finally the name or IP address of the domain controller. After that, calling functions is straight forward.


How it Works

In order to communicate with Active Directory all connection information should be provided:

  • Domain Name
  • Domain Computer Name/IP
  • Administrator Username
  • Administrator Password
Application Function
Create Creates a new user
Exists Returns True or False depending on whether the user exists in Active Directory or not
Enable Enables the account of the Active Directory user provided
Disable Disables the account of the Active Directory user provided
Set Password Changes the password of the given user with a new password
Set Group Adds the given user to a given user group.


How to use the class functions

Set up

DotnetAD.ADAdminUser = "administrator";

DotnetAD.ADAdminPassword = "password";

DotnetAD.ADFullPath = "LDAP://" + "domain.com";

DotnetAD.ADServer = "";


Adding a user

DirectoryEntry user = DotnetAD.CreateNewUser(this.TxtUsername.Text);


Checking if user exists



Adding a user to a group

DotnetAD.AddUserToGroup("TestUser", "Administrators");


Enabling an Active Directory user



Disabling an Active Directory user



Set an Active Directory user's password

DotnetAD.SetUserPassword(this.TxtUsername.Text, this.TxtUserPassword.Text);