1 /* search.c - shell backend search function */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/socket.h>
13 #include <ac/string.h>
30 struct berval *filterstr,
35 struct shellinfo *si = (struct shellinfo *) be->be_private;
40 if ( si->si_search == NULL ) {
41 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
42 "search not implemented", NULL, NULL );
46 if ( (op->o_private = (void *) forkandexec( si->si_search, &rfp, &wfp ))
48 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
49 "could not fork/exec", NULL, NULL );
53 /* write out the request to the search process */
54 fprintf( wfp, "SEARCH\n" );
55 fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
56 print_suffixes( wfp, be );
57 fprintf( wfp, "base: %s\n", base->bv_val );
58 fprintf( wfp, "scope: %d\n", scope );
59 fprintf( wfp, "deref: %d\n", deref );
60 fprintf( wfp, "sizelimit: %d\n", size );
61 fprintf( wfp, "timelimit: %d\n", time );
62 fprintf( wfp, "filter: %s\n", filterstr->bv_val );
63 fprintf( wfp, "attrsonly: %d\n", attrsonly ? 1 : 0 );
64 fprintf( wfp, "attrs:%s", attrs == NULL ? " all" : "" );
65 for ( an = attrs; an && an->an_name.bv_val; an++ ) {
66 fprintf( wfp, " %s", an->an_name.bv_val );
71 /* read in the results and send them along */
72 read_and_send_results( be, conn, op, rfp, attrs, attrsonly );