/** {@inheritDoc} */ public LDAPConnection getConnection() throws LDAPException { if (M_log.isDebugEnabled()) { M_log.debug("getConnection()"); } LDAPConnection conn = newConnection(); if (config.isAutoBind()) { if (M_log.isDebugEnabled()) { M_log.debug("getConnection(): auto-binding"); } try { bind(conn, config.getLdapUser(), config.getLdapPassword()); } catch (LDAPException ldape) { if (ldape.getResultCode() == LDAPException.INVALID_CREDENTIALS) { M_log.warn( "Failed to bind against: " + conn.getHost() + " with user: "******" password: "******".", "*")); } throw ldape; } } return conn; }
/** * Determines if the supplied ldap exception should result in an operation retry. * * @param e that was produced * @throws LdapException wrapping the ldap exception */ protected void processLDAPException(final LDAPException e) throws LdapException { ProviderUtils.throwOperationException( config.getOperationExceptionResultCodes(), e, e.getResultCode(), e.getMatchedDN(), null, null, true); }
/** {@inheritDoc} */ @Override public void close(final RequestControl[] controls) throws LdapException { try { if (connection != null) { connection.disconnect(getLDAPConstraints(controls)); } } catch (LDAPException e) { throw new LdapException(e, ResultCode.valueOf(e.getResultCode())); } finally { connection = null; } }
/** * Determines whether the supplied ldap exception should be ignored. * * @param ignoreResultCodes to match against the exception * @param e ldap exception to match * @return result code that should be ignored or null */ protected ResultCode ignoreSearchException( final ResultCode[] ignoreResultCodes, final LDAPException e) { ResultCode ignore = null; if (ignoreResultCodes != null && ignoreResultCodes.length > 0) { for (ResultCode rc : ignoreResultCodes) { if (e.getResultCode() == rc.value()) { logger.debug("Ignoring ldap exception", e); ignore = rc; break; } } } return ignore; }