Ejemplo n.º 1
0
  /** {@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;
  }
Ejemplo n.º 2
0
 /**
  * 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);
 }
Ejemplo n.º 3
0
 /** {@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;
   }
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }