Code example for SearchControls

Methods: setCountLimitsetDerefLinkFlagsetSearchScope

0
     */ 
    private String getUserCredentials(String username) throws LoginExceptionString ldapCredential = null;
 
        SearchControls ctls = new SearchControls();
        ctls.setCountLimit(1);
        ctls.setDerefLinkFlag(true);
        ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
 
        String filter = "(&(objectClass={0})({1}={2}))";
 
        LOG.debug("Searching for users with filter: \'" + filter + "\'" + " from base dn: " + _userBaseDn);
 
        try 
        { 
            Object[] filterArguments = {_userObjectClass, _userIdAttribute, username}; 
            NamingEnumeration<SearchResult> results = _rootContext.search(_userBaseDn, filter, filterArguments, ctls);
 
            LOG.debug("Found user?: " + results.hasMoreElements());
 
            if (!results.hasMoreElements())
            {