예제 #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;
  }