Authenticate User in Active Directory using C# or VB.Net
This function enables a username and password to be authenticated against
Active Directory, as with Login the caller does not need to be logged into the
domain, if the AD server is visible it can be called.
Langauges Supported
ASP.NET, C#, VB.Net, Visual Studio 2010, Visual Sutdio 2008
Method: Authenticate
Parameters: (string) Username, (string) Password
Precondition
An instance of the LDAP manager must be instantiated for a valid ADDS server.
Functionality
The method is called passing the Username and the Password as strings. Three
things can then occur:
- If authorization is successful the method returns true.
- If authorization is unsuccessful the
method returns false
- An Exception will be thrown for other errors
Example
Where LdapConnection is an instance of LdapManager
public Boolean AuthorizeLDAP(String UserName, String PassWord)
{
try
{
return LdapConnection.Authenticate(UserName, PassWord);
}
catch (Exception)
{
throw;
}
}
Post Condition
It should be noted that there is no residual connection to the authenticated
User Name, this method does not result in any "Login" context.
|