Class LdapUtil

java.lang.Object
fr.paris.lutece.util.ldap.LdapUtil

public final class LdapUtil extends Object
This class provides LDAP generic connection methods
  • Method Details

    • getContext

      public static DirContext getContext(String strLDAPContext, String strLDAPUrl, String strAdminDN, String strAdminPassword) throws NamingException
      LDAP Context search
      Parameters:
      strLDAPContext - the context
      strLDAPUrl - the url
      strAdminDN - the admin dn to use
      strAdminPassword - the admin password to use
      Returns:
      a DirContext object
      Throws:
      NamingException - in case of error
    • freeContext

      public static void freeContext(DirContext context) throws NamingException
      Close the context given in parameter
      Parameters:
      context - the LDAP context as a DirContext object
      Throws:
      NamingException - in case of error
    • bindUser

      public static DirContext bindUser(String strLDAPContext, String strLDAPUrl, String strDN, String strPassword) throws NamingException
      Parameters:
      strLDAPContext - the context
      strLDAPUrl - the url
      strDN - the dn of the user to connect
      strPassword - the password of the user to connect
      Returns:
      a DirContext object
      Throws:
      NamingException - in case of error
    • searchUsers

      public static NamingEnumeration<SearchResult> searchUsers(DirContext context, String strFilter, String strUserDN, String strDNBase, SearchControls sc) throws NamingException
      Parameters:
      context - the context
      strFilter - the filter for the search
      strUserDN - the user dn
      strDNBase - the base dn
      sc - the SearchControls
      Returns:
      an enumeration of the elements found
      Throws:
      NamingException - in case of error