1 /* compare.c - monitor backend compare routine */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2005 The OpenLDAP Foundation.
6 * Portions Copyright 2001-2003 Pierangelo Masarati.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by Pierangelo Masarati for inclusion
19 * in OpenLDAP Software.
27 #include "back-monitor.h"
30 monitor_back_compare( struct slap_op *op, struct slap_rep *rs)
32 struct monitorinfo *mi =
33 (struct monitorinfo *) op->o_bd->be_private;
34 Entry *e, *matched = NULL;
37 /* get entry with reader lock */
38 monitor_cache_dn2entry( op, &op->o_req_ndn, &e, &matched );
40 rs->sr_err = LDAP_NO_SUCH_OBJECT;
42 rs->sr_matched = matched->e_dn;
44 send_ldap_result( op, rs );
46 monitor_cache_release( mi, matched );
47 rs->sr_matched = NULL;
53 rs->sr_err = access_allowed( op, e, op->oq_compare.rs_ava->aa_desc,
54 &op->oq_compare.rs_ava->aa_value, ACL_COMPARE, NULL );
56 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
60 rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE;
62 for ( a = attrs_find( e->e_attrs, op->oq_compare.rs_ava->aa_desc );
64 a = attrs_find( a->a_next, op->oq_compare.rs_ava->aa_desc )) {
65 rs->sr_err = LDAP_COMPARE_FALSE;
67 if ( value_find_ex( op->oq_compare.rs_ava->aa_desc,
68 SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
69 SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
70 a->a_nvals, &op->oq_compare.rs_ava->aa_value,
71 op->o_tmpmemctx ) == 0 )
73 rs->sr_err = LDAP_COMPARE_TRUE;
79 send_ldap_result( op, rs );
80 if ( rs->sr_err == LDAP_COMPARE_FALSE
81 || rs->sr_err == LDAP_COMPARE_TRUE ) {
82 rs->sr_err = LDAP_SUCCESS;
85 monitor_cache_release( mi, e );