How to develop a new LDAP Utils implementation

This section shows how to supply your own LDAP implementation for the API. It might be useful if you want to borrow some concepts of LDAP Utils on your implementation, or if you want to reuse parts of the LDAP Utils implementation.

The ILDAPUtils interface

The LDAP Utils API is defined by the ILDAPUtils interface and any new LDAP Utils implementation must conform to it.

This interface defines the expected behavior for the API. It includes typical operations executed on LDAP servers such as:

  • getting user and group information from the LDAP server
  • create, modify and remove users and groups
  • verifying a user's credentials
  • define association relations between users and groups
  • provide means of verifying the afforementioned user/group relations

Using the AbstractLDAPUtils abstract class as implementations base class

The AbstractLDAPUtils is the standard base implementation of the LDAP Utils API as specified by the ILDAPUtils interface. This class provides default implementations of most of the interface's methods. Some technology specific methods implementations are delegated to subclasses. Since these implementations are common to several LDAP technologies they were placed on the base class to be available for the subclasses. As such the AbstractLDAPUtils class can be used as a starting point for the new implementation.

The technology specific details not implemented on the base class are:

  • the LDAP user and group object class names (schema dependent)
  • some LDAP utils specific attribute names (parent group)
  • the way to calculate the entity's distinguished names (might be technology-specific)
  • some other features that the programmer might choose/need to override (the password changing method, which might be technology-specific, for example).

Here's the list of abstract methods that must be implemented:

    abstract protected String getUserClassName();
    abstract protected String getGroupClassName();
    
    abstract protected String getUserParentGroupAttributeName();
    abstract protected String getGroupParentGroupAttributeName();
    
    abstract protected String calculateDistinguishedName(String commonName, String mainGroupCommonName);

The following method might be implemented as well, if the programmer wishes so or if the used LDAP technology forces to:

    public void changePassword(String loginName, String newPassword) throws LDAPOperationException ;

For a complete in-depth view of the AbstractLDAPUtils class read this page.

Starting from scratch

If you have the need for a specific LDAP technology you can opt to implement everything from scratch. To do so, simply make you class implement the ILDAPUtils interface and supply the adequate implementation logic.