public void reconnect() throws LDAPException {
    final String host = getHost();
    final int port = getPort();
    final String dn = authDN;
    final String pw = authPW;

    conn.close();

    if ((dn == null) || (pw == null)) {
      connect(host, port);
    } else {
      connect(host, port, dn, pw);
    }
  }
  public void connect(
      final int version,
      final String host,
      final int port,
      final String dn,
      final String password,
      final LDAPConstraints constraints)
      throws LDAPException {
    connect(host, port);

    try {
      if ((dn != null) && (password != null)) {
        bind(version, dn, password, constraints);
      }
    } catch (LDAPException le) {
      conn.close();
      throw le;
    }
  }
  @Override()
  protected void finalize() throws Throwable {
    conn.close();

    super.finalize();
  }
 public void disconnect() throws LDAPException {
   conn.close();
   authDN = null;
   authPW = null;
 }