1 /* search.c - shell backend search function */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/socket.h>
13 #include <ac/string.h>
23 struct shellinfo *si = (struct shellinfo *) op->o_bd->be_private;
27 if ( si->si_search == NULL ) {
28 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
29 "search not implemented" );
33 if ( (op->o_private = (void *) forkandexec( si->si_search, &rfp, &wfp ))
35 send_ldap_error( op, rs, LDAP_OTHER,
36 "could not fork/exec" );
40 /* write out the request to the search process */
41 fprintf( wfp, "SEARCH\n" );
42 fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
43 print_suffixes( wfp, op->o_bd );
44 fprintf( wfp, "base: %s\n", op->o_req_dn.bv_val );
45 fprintf( wfp, "scope: %d\n", op->oq_search.rs_scope );
46 fprintf( wfp, "deref: %d\n", op->oq_search.rs_deref );
47 fprintf( wfp, "sizelimit: %d\n", op->oq_search.rs_slimit );
48 fprintf( wfp, "timelimit: %d\n", op->oq_search.rs_tlimit );
49 fprintf( wfp, "filter: %s\n", op->oq_search.rs_filterstr.bv_val );
50 fprintf( wfp, "attrsonly: %d\n", op->oq_search.rs_attrsonly ? 1 : 0 );
51 fprintf( wfp, "attrs:%s", op->oq_search.rs_attrs == NULL ? " all" : "" );
52 for ( an = op->oq_search.rs_attrs; an && an->an_name.bv_val; an++ ) {
53 fprintf( wfp, " %s", an->an_name.bv_val );
58 /* read in the results and send them along */
59 rs->sr_attrs = op->oq_search.rs_attrs;
60 read_and_send_results( op, rs, rfp );