Thursday, 23 August 2012

What is LDAP?

The LDAP (Lightweight Directory Access Protocol) is an application protocol for accessing and maintaining distributed directory information services over an Internate Protocol (IP) network.
         Directory Services may provide any organized set of records, often with a hierarchical structure, such as a corporate mail directory. Similarly, a addressbook is a list of subscribers with an address and a phone number.

Default Port for LDAP Connection :

The default port for LDAP over SSL is 636 and over TCP is 389


LDAP connection through Java code:

LDAPConnection getNewLdapConnection(){


       int ldapPort = LDAPConnection.DEFAULT_PORT;

        String ldapHost       = "xxx.services.sytem";

        String loginDN        = "cn=yyy,ou=users,ou=services,o=sytem";


        String password       = "private";


    int ldapVersion  = LDAPConnection.LDAP_V3;

      


        LDAPConnection connection = new LDAPConnection();


        try {


           // connect to the server

            connection.connect( ldapHost, ldapPort );


           // authenticate to the server

            connection.bind( ldapVersion, loginDN, password.getBytes("UTF8") );

                   


        } catch(LDAPException e){}

return connection;

}