1 /* compare.c - shell backend compare function */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
13 #include <ac/socket.h>
25 AttributeAssertion *ava
28 struct shellinfo *si = (struct shellinfo *) be->be_private;
29 AttributeDescription *entry = slap_schema.si_ad_entry;
33 if ( si->si_compare == NULL ) {
34 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
35 "compare not implemented", NULL, NULL );
48 if ( ! access_allowed( be, conn, op, &e,
49 entry, NULL, ACL_READ, NULL ) )
51 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
52 NULL, NULL, NULL, NULL );
56 if ( (op->o_private = (void *) forkandexec( si->si_compare, &rfp, &wfp ))
58 send_ldap_result( conn, op, LDAP_OTHER, NULL,
59 "could not fork/exec", NULL, NULL );
64 * FIX ME: This should use LDIF routines so that binary
65 * values are properly dealt with
68 /* write out the request to the compare process */
69 fprintf( wfp, "COMPARE\n" );
70 fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
71 print_suffixes( wfp, be );
72 fprintf( wfp, "dn: %s\n", dn->bv_val );
73 fprintf( wfp, "%s: %s\n",
74 ava->aa_desc->ad_cname.bv_val,
75 ava->aa_value.bv_val /* could be binary! */ );
78 /* read in the result and send it along */
79 read_and_send_results( be, conn, op, rfp, NULL, 0 );