Ejemplo n.º 1
0
  /**
   * Performs a search operation with the {@link DirSyncControl}. The supplied request is modified
   * in the following way:
   *
   * <ul>
   *   <li>{@link SearchRequest#setControls( org.ldaptive.control.RequestControl...)} is invoked
   *       with {@link DirSyncControl}, {@link ShowDeletedControl}, and {@link ExtendedDnControl}
   * </ul>
   *
   * <p>The cookie is extracted from the supplied response and replayed in the request.
   *
   * @param request search request to execute
   * @param response of a previous dir sync operation
   * @return search operation response
   * @throws LdapException if the search fails
   */
  public Response<SearchResult> execute(
      final SearchRequest request, final Response<SearchResult> response) throws LdapException {
    final byte[] cookie = getDirSyncCookie(response);
    if (cookie == null) {
      throw new IllegalArgumentException("Response does not contain a dir sync cookie");
    }

    final SearchOperation search = new SearchOperation(connection);
    request.setControls(createRequestControls(null));
    return search.execute(request);
  }
Ejemplo n.º 2
0
 /**
  * Performs a search operation with the {@link DirSyncControl}. The supplied request is modified
  * in the following way:
  *
  * <ul>
  *   <li>{@link SearchRequest#setControls( org.ldaptive.control.RequestControl...)} is invoked
  *       with {@link DirSyncControl}, {@link ShowDeletedControl}, and {@link ExtendedDnControl}
  * </ul>
  *
  * <p>This method will continue to execute search operations until all dir sync search results
  * have been retrieved from the server. The returned response contains the response data of the
  * last dir sync operation plus the entries and references returned by all previous search
  * operations.
  *
  * @param request search request to execute
  * @return search operation response of the last dir sync operation
  * @throws LdapException if the search fails
  */
 public Response<SearchResult> executeToCompletion(final SearchRequest request)
     throws LdapException {
   Response<SearchResult> response = null;
   final SearchResult result = new SearchResult();
   final SearchOperation search = new SearchOperation(connection);
   byte[] cookie = null;
   long flags;
   do {
     if (response != null && response.getResult() != null) {
       result.addEntries(response.getResult().getEntries());
       result.addReferences(response.getResult().getReferences());
     }
     request.setControls(createRequestControls(cookie));
     response = search.execute(request);
     flags = getDirSyncFlags(response);
     cookie = getDirSyncCookie(response);
   } while (flags != 0);
   response.getResult().addEntries(result.getEntries());
   response.getResult().addReferences(result.getReferences());
   return response;
 }
Ejemplo n.º 3
0
 /**
  * Performs a search operation with the {@link DirSyncControl}. The supplied request is modified
  * in the following way:
  *
  * <ul>
  *   <li>{@link SearchRequest#setControls( org.ldaptive.control.RequestControl...)} is invoked
  *       with {@link DirSyncControl}, {@link ShowDeletedControl}, and {@link ExtendedDnControl}
  * </ul>
  *
  * @param request search request to execute
  * @return search operation response
  * @throws LdapException if the search fails
  */
 public Response<SearchResult> execute(final SearchRequest request) throws LdapException {
   final SearchOperation search = new SearchOperation(connection);
   request.setControls(createRequestControls(null));
   return search.execute(request);
 }