コード例 #1
0
  public SearchResponse search(SearchRequest request, SearchResponse response) throws Exception {
    Session session = createAdminSession();
    LDAPClient client = null;

    try {
      LDAPConnection connection = (LDAPConnection) getConnection();
      client = connection.getClient(session);
      client.search(request, response);

      int rc = response.waitFor();
      log.debug("RC: " + rc);

    } catch (Exception e) {
      response.setException(e);

    } finally {
      if (client != null)
        try {
          client.close();
        } catch (Exception e) {
          log.error(e.getMessage(), e);
        }
      if (session != null)
        try {
          session.close();
        } catch (Exception e) {
          log.error(e.getMessage(), e);
        }
      response.close();
    }

    return response;
  }
コード例 #2
0
  public SearchResult find(DN dn) throws Exception {
    Session session = createAdminSession();
    LDAPClient client = null;

    try {
      LDAPConnection connection = (LDAPConnection) getConnection();
      client = connection.getClient(session);
      return client.find(dn);

    } finally {
      if (client != null)
        try {
          client.close();
        } catch (Exception e) {
          log.error(e.getMessage(), e);
        }
      if (session != null)
        try {
          session.close();
        } catch (Exception e) {
          log.error(e.getMessage(), e);
        }
    }
  }