1 /* search.c - shell backend search function */
6 #include <sys/socket.h>
10 extern Entry *str2entry();
28 struct shellinfo *si = (struct shellinfo *) be->be_private;
29 int i, rc, bsize, len;
34 if ( si->si_search == NULL ) {
35 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
36 "search not implemented" );
40 if ( (op->o_private = forkandexec( si->si_search, &rfp, &wfp ))
42 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
43 "could not fork/exec" );
47 /* write out the request to the search process */
48 fprintf( wfp, "SEARCH\n" );
49 fprintf( wfp, "msgid: %d\n", op->o_msgid );
50 print_suffixes( wfp, be );
51 fprintf( wfp, "base: %s\n", base );
52 fprintf( wfp, "scope: %d\n", scope );
53 fprintf( wfp, "deref: %d\n", deref );
54 fprintf( wfp, "sizelimit: %d\n", size );
55 fprintf( wfp, "timelimit: %d\n", time );
56 fprintf( wfp, "filter: %s\n", filterstr );
57 fprintf( wfp, "attrsonly: %d\n", attrsonly ? 1 : 0 );
58 fprintf( wfp, "attrs:%s", attrs == NULL ? " all" : "" );
59 for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) {
60 fprintf( wfp, " %s", attrs[i] );
65 /* read in the results and send them along */
66 read_and_send_results( be, conn, op, rfp, attrs, attrsonly );