/** * Returns the result code from the exception. * * @see <a href="../../../../api/com/novell/ldap/LDAPException.html#getResultCode()"> com.novell.ldap.LDAPException.getResultCode()</a> */ public int getResultCode() { return exception.getResultCode( ); }
/** * Check if provided password is correct provided users's password. * * @param userDN the user. * @param password the password. * @param passwordField the name of the LDAP field containing the password. * @return true if the password is valid, false otherwise. */ public boolean checkPassword(String userDN, String password, String passwordField) { try { LDAPAttribute attribute = new LDAPAttribute(passwordField, password); return this.connection.compare(userDN, attribute); } catch (LDAPException e) { if (e.getResultCode() == LDAPException.NO_SUCH_OBJECT) { LOGGER.debug("Unable to locate user_dn [{}]", userDN, e); } else if (e.getResultCode() == LDAPException.NO_SUCH_ATTRIBUTE) { LOGGER.debug("Unable to verify password because userPassword attribute not found.", e); } else { LOGGER.debug("Unable to verify password", e); } } return false; }
switch (((LDAPException)e).getResultCode()){ case LDAPException.DECODING_ERROR: error.setAttribute("type", "malformedRequest");
/** * Check if provided password is correct provided users's password. * * @param userDN the user. * @param password the password. * @param passwordField the name of the LDAP field containing the password. * @return true if the password is valid, false otherwise. */ public boolean checkPassword(String userDN, String password, String passwordField) { try { LDAPAttribute attribute = new LDAPAttribute(passwordField, password); return this.connection.compare(userDN, attribute); } catch (LDAPException e) { if (e.getResultCode() == LDAPException.NO_SUCH_OBJECT) { if (LOG.isDebugEnabled()) { LOG.debug("Unable to locate user_dn:" + userDN, e); } } else if (e.getResultCode() == LDAPException.NO_SUCH_ATTRIBUTE) { if (LOG.isDebugEnabled()) { LOG.debug("Unable to verify password because userPassword attribute not found.", e); } } else { if (LOG.isDebugEnabled()) { LOG.debug("Unable to verify password", e); } } } return false; }
/** * {@inheritDoc} */ public LDAPConnection getConnection() throws LDAPException { if ( log.isDebugEnabled() ) { log.debug("getConnection()"); } LDAPConnection conn = newConnection(); if ( config.isAutoBind() ) { if ( log.isDebugEnabled() ) { log.debug("getConnection(): auto-binding"); } try { bind(conn, config.getLdapUser(), config.getLdapPassword()); } catch (LDAPException ldape) { if (ldape.getResultCode() == LDAPException.INVALID_CREDENTIALS) { log.warn("Failed to bind against: "+ conn.getHost()+ " with user: "+ config.getLdapUser()+ " password: "+ config.getLdapPassword().replaceAll(".", "*")); } throw ldape; } } return conn; }
/** * Find all user objects which have this email address. * * @param email * The email address string. * @param factory * To create all the UserEdit objects you populate and return in the return collection. * @return Collection (UserEdit) of user objects that have this email address, or an empty Collection if there are none. */ @SuppressWarnings("rawtypes") public Collection findUsersByEmail(String email, UserFactory factory) { String filter = ldapAttributeMapper.getFindUserByEmailFilter(email); List<User> users = new ArrayList<User>(); try { List<LdapUserData> ldapUsers = searchDirectory(filter, null, null, null, null, maxResultSize); for(LdapUserData ldapUserData: ldapUsers) { //SAK-20625 ensure we have an id-eid mapping at this time UserEdit user = factory.newUser(ldapUserData.getEid()); mapUserDataOntoUserEdit(ldapUserData, user); users.add(user); } } catch (LDAPException e) { log.warn("An error occurred finding users by email: " + e.getClass().getName() + ": (" + e.getResultCode() + ") " + e.getMessage()); return null; } return users; }
out.write("<errorResponse type=\""); if (e instanceof LDAPException){ switch (((LDAPException)e).getResultCode()){ case LDAPException.DECODING_ERROR: case LDAPException.PROTOCOL_ERROR: if (e instanceof LDAPException) { LDAPException le = (LDAPException) e; String msg = Integer.toString(le.getResultCode()) + ":" + le.getMessage(); out.write(makeXMLSafe(msg)); } else {
switch (e.getResultCode()) { case LDAPException.INVALID_CREDENTIALS: log.warn("authenticateUser(): invalid credentials [userLogin = " + userLogin + "]");
log.warn("An error occurred searching for users: " + e.getClass().getName() + ": (" + e.getResultCode() + ") " + e.getMessage()); return null;
System.out.println("Error : " + e.getResultCode());