.NET Active Directory Wrapper

   Access Active Directory From Your Code

View DotNet Active Directory Wrapper Plus Demo
 

Active Directory
Introduction
Objects
Object Properties

DirectoryServices Namespace
Introduction
DirectoryEntry Class

How to .. in C# .NET
Create User
Disable User
Enable User
Authenticate a User
Change User Password
Get DirectoryEntry of a user
Get Users in a Group
Get Object Property

Other Resources
References

How to authenticate an Active Directory user

public static DotnetAD.LoginResult Login(string UserName, string Password)
{
//first, check if the logon exists based on the username and password
//DirectoryEntry de = GetUser(UserName,Password);

if(IsUserValid(UserName,Password))
{
DirectoryEntry de = GetUser(UserName);
if(de !=null)
{
//convert the accountControl value so that a logical operation can be performed
//to check of the Disabled option exists.
int userAccountControl = Convert.ToInt32(de.Properties["userAccountControl"][0]);
de.Close();

//if the disabled item does not exist then the account is active
if(!IsAccountActive(userAccountControl))
{
return LoginResult.LOGIN_USER_ACCOUNT_INACTIVE;
}
else
{
return LoginResult.LOGIN_OK;
}

}
else
{
return LoginResult.LOGIN_USER_DOESNT_EXIST;
}
}
else
{
return LoginResult.LOGIN_USER_DOESNT_EXIST;
}
}