1 /* compare.c - sock backend compare function */
2 /* $OpenLDAP: pkg/ldap/servers/slapd/back-sock/compare.c,v 1.4.2.1 2008/02/09 00:46:09 quanah Exp $ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2008 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was initially developed by Brian Candler for inclusion
18 * in OpenLDAP Software.
25 #include <ac/string.h>
26 #include <ac/socket.h>
29 #include "back-sock.h"
36 struct sockinfo
*si
= (struct sockinfo
*) op
->o_bd
->be_private
;
37 AttributeDescription
*entry
= slap_schema
.si_ad_entry
;
42 e
.e_name
= op
->o_req_dn
;
43 e
.e_nname
= op
->o_req_ndn
;
50 if ( ! access_allowed( op
, &e
,
51 entry
, NULL
, ACL_COMPARE
, NULL
) )
53 send_ldap_error( op
, rs
, LDAP_INSUFFICIENT_ACCESS
, NULL
);
57 if ( (fp
= opensock( si
->si_sockpath
)) == NULL
) {
58 send_ldap_error( op
, rs
, LDAP_OTHER
,
59 "could not open socket" );
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( fp
, "COMPARE\n" );
70 fprintf( fp
, "msgid: %ld\n", (long) op
->o_msgid
);
71 sock_print_conn( fp
, op
->o_conn
, si
);
72 sock_print_suffixes( fp
, op
->o_bd
);
73 fprintf( fp
, "dn: %s\n", op
->o_req_dn
.bv_val
);
74 fprintf( fp
, "%s: %s\n",
75 op
->oq_compare
.rs_ava
->aa_desc
->ad_cname
.bv_val
,
76 op
->oq_compare
.rs_ava
->aa_value
.bv_val
/* could be binary! */ );
79 /* read in the result and send it along */
80 sock_read_and_send_results( op
, rs
, fp
);