java-8unboundid-ldap-sdk

What are the authentication steps of UnboundID LDAP SDK


I am implementing a LDAP client to LDAP server which make a connection with the server and do authentication.What steps do I need to follow?


Solution

  • There are lot of options in UnboundID LDAP. You can use connection pool if you want and that will reduce extra load on LDAP server at the connection establishment.

    To make the connection pool

    try {
         connection = new LDAPConnection(address, port);
         BindResult bindResult = connection.bind(DN, password);
         connectionPool = new LDAPConnectionPool(connection, max_numbof_connection);     
    } catch (LDAPException e) {
         String es = e.getExceptionMessage();
         System.out.println(es);
    }
    

    You can achieve this by making a single connection too. First you need to make an unauthenticated connection using address and port and then bind that connection using a DN and password. At the bind request you may find whether given DN is an authorized one or not.

    Example for authenticate user from a connection without Connection pool

    LDAPConnection connection = new LDAPConnection();
    connection.connect("server.example.com", 389);
    connection.bind("uid=john.doe,ou=People,dc=example,dc=com", "password");