/** * Disconnects the given LDAP connection, logging any failure to do so * appropriately. * * @param ldapConnection * The LDAP connection to disconnect. */ public void disconnect(LDAPConnection ldapConnection) { // Attempt disconnect try { ldapConnection.disconnect(); } // Warn if disconnect unexpectedly fails catch (LDAPException e) { logger.warn("Unable to disconnect from LDAP server: {}", e.getMessage()); logger.debug("LDAP disconnect failed.", e); } }
public Map<String, Object> get() { if (handleEndOfResults()) return null; try { Map<String, Object> entry = new LinkedHashMap<>(attributes.size() + 1); LDAPEntry en = null; en = lsr.next(); entry.put("dn", en.getDN()); if (attributes != null && attributes.size() > 0) { for (int col = 0; col < attributes.size(); col++) { Object val = readValue(en.getAttributeSet().getAttribute(attributes.get(col))); if (val != null) entry.put(attributes.get(col),val ); } } else { // make it dynamic Iterator<LDAPAttribute> iter = en.getAttributeSet().iterator(); while (iter.hasNext()) { LDAPAttribute attr = iter.next(); Object val = readValue(attr); if (val != null) entry.put(attr.getName(), readValue(attr)); } } //System.out.println("entry " + entry); return entry; } catch (LDAPException e) { e.printStackTrace(); throw new RuntimeException("Error getting next ldap entry " + e.getLDAPErrorMessage()); } }
/** * 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; }
public void printStackTrace() { exception.printStackTrace(); return; }
switch (e.getResultCode()) { case LDAPException.INVALID_CREDENTIALS: log.warn("authenticateUser(): invalid credentials [userLogin = " + userLogin + "]"); return false; case LDAPException.UNWILLING_TO_PERFORM: log.warn("authenticateUser(): ldap service is unwilling to authenticate [userLogin = " + userLogin + "][reason = " + e.getLDAPErrorMessage() + "]"); return false; default: throw new RuntimeException( "authenticateUser(): LDAPException during authentication attempt [userLogin = " + userLogin + "][result code = " + e.resultCodeToString() + "][error message = " + e.getLDAPErrorMessage() + "]", e);
/** * 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( ); }
throw new RuntimeException("getUsers(): LDAPException during search [eid = " + (userEdit == null ? null : userEdit.getEid()) + "][result code = " + e.resultCodeToString() + "][error message = " + e.getLDAPErrorMessage() + "]", e); } catch ( Exception e ) { abortiveSearch = true;
final String ldapErrorMessage = e.getLDAPErrorMessage(); if ( ldapErrorMessage != null ) LOGGER.error( "NMASLoginMonitor: LDAPException " + e.toString() );
/** * Returns a string representing the specified result code in the * specified locale. * * @see <a href="../../../../api/com/novell/ldap/LDAPException.html#resultCodeToString(int, java.util.Locale)"> com.novell.ldap.LDAPException.resultCodeToString(int, Locale)</a> */ public static String resultCodeToString( int code, Locale locale ) { return com.novell.ldap.LDAPException.resultCodeToString( code, locale); }
throw new LDAPException(LDAPException.resultCodeToString(LDAPException.INVALID_CREDENTIALS),LDAPException.INVALID_CREDENTIALS,LDAPException.resultCodeToString(LDAPException.INVALID_CREDENTIALS)); } else { throw new LDAPException(LDAPException.resultCodeToString(LDAPException.UNAVAILABLE),LDAPException.UNAVAILABLE,post.getStatusText());
/** * Returns the error message from the LDAP server, if this message is * available (that is, if this message was set). * * @see <a href="../../../../api/com/novell/ldap/LDAPException.html#getLDAPErrorMessage()"> com.novell.ldap.LDAPException.getLDAPErrorMessage()</a> */ public String getLDAPErrorMessage() { return exception.getLDAPErrorMessage( ); }
LDAPException e = new LDAPException( null, LDAPException.LDAP_TIMEOUT,(String)null); entries.addElement(e ); if( Debug.LDAP_DEBUG ) { Debug.trace( Debug.messages, name + "Caught exception, add to entry queue: " + e.toString());
/** * Converts the integer error value to a string, in the default locale. * * @see <a href="../../../../api/com/novell/ldap/LDAPException.html#toString()"> com.novell.ldap.LDAPException.toString()</a> */ public String toString() { return exception.toString( ); }
log.warn("An error occurred searching for users: " + e.getClass().getName() + ": (" + e.getResultCode() + ") " + e.getMessage()); return null;
public void printStackTrace(java.io.PrintStream stream) { exception.printStackTrace(stream); return; }
/** * 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; }
/** * Returns a string representing the result code in the * specified locale. * * @see <a href="../../../../api/com/novell/ldap/LDAPException.html#resultCodeToString(java.util.Locale)"> com.novell.ldap.LDAPException.resultCodeToString(Locale)</a> */ public String resultCodeToString( Locale locale ) { return exception.resultCodeToString( locale); }
break; default: // Everything else ex = new LDAPException( LDAPException.resultCodeToString( getResultCode()), getResultCode(), getErrorMessage(), getMatchedDN()); break;
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 {
logger.error("Unable to connect to LDAP server: {}", e.getMessage()); logger.debug("Failed to connect to LDAP server.", e); return null;