Class LdapUtil


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

      • 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