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

Login to Active directory Using .Net Wrapper

This method enables you to login and bind to an Active Directory Domain Service (ADDS) using Lightweight Directory Access Protocol (LDAP), an essential first step to querying and updating the Active Directory. One of the benefits of using LDAP is that the client does not need to be logged onto the server domain; as long as the server IP is visible it should be possible to login, subject to firewall restrictions.

Langauges Supported

ASP.NET, C#, VB.Net, Visual Studio 2010, Visual Sutdio 2012

Method Name: Login

Parameters:  (string) Username, (string) Password

Precondition

An instance of the LDAP manager must be instantiated for a valid ADDS server.

Example:  LdapManager myLDAP = new LdapManager("ADDS_Server_Name");

Exception handling should enclose this statement.

Functionality

The method is called passing the Username and the Password as strings. Three things can then occur:

  1. If authentication is successful the LdapManager object is bound to the ADDS server and the method returns true.
  2. If authentication is unsuccessful the method returns false
  3. An Exception will be thrown for other errors

Examples

Two important aspects to implementing login are that you will need to use the LdapManager object after you Login and also you will need to trap any exception that occurs during the instantiation of the object and the authentication of the login.

public class thisLDAP
    {
        LdapManager LdapConnection;
        public thisLDAP(String Servername)
        {
            try
            {
                LdapConnection = new LdapManager(Servername);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public Boolean LoginLDAP(String UserName, String PassWord)
        {
            try
            {
                return LdapConnection.Login(UserName, PassWord);
            }
            catch (Exception)
            {               
                throw;               
            }
        }

Post condition

The successfully authenticated object has full access to the Active Directory; this object should be treated with discretion and disposed of after use.

Conclusion This method does not appear to allow an SSL connection, and one can assume that it connects to the server using port 389. A facility to recall a list of recent servers from a resource would be useful. The logon is simple to achieve and is tailored to using the ADDS, which is not the case for generic LDAP clients.