| 1 |
/* compare.c - monitor backend compare routine */ |
| 2 |
/* $OpenLDAP$ */ |
| 3 |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
| 4 |
* |
| 5 |
* Copyright 2001-2024 The OpenLDAP Foundation. |
| 6 |
* Portions Copyright 2001-2003 Pierangelo Masarati. |
| 7 |
* All rights reserved. |
| 8 |
* |
| 9 |
* Redistribution and use in source and binary forms, with or without |
| 10 |
* modification, are permitted only as authorized by the OpenLDAP |
| 11 |
* Public License. |
| 12 |
* |
| 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>. |
| 16 |
*/ |
| 17 |
/* ACKNOWLEDGEMENTS: |
| 18 |
* This work was initially developed by Pierangelo Masarati for inclusion |
| 19 |
* in OpenLDAP Software. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "portable.h" |
| 23 |
|
| 24 |
#include <stdio.h> |
| 25 |
|
| 26 |
#include <slap.h> |
| 27 |
#include "back-monitor.h" |
| 28 |
|
| 29 |
int |
| 30 |
monitor_back_compare( Operation *op, SlapReply *rs ) |
| 31 |
{ |
| 32 |
monitor_info_t *mi = ( monitor_info_t * ) op->o_bd->be_private; |
| 33 |
Entry *e, *matched = NULL; |
| 34 |
int rc; |
| 35 |
|
| 36 |
/* get entry with reader lock */ |
| 37 |
monitor_cache_dn2entry( op, rs, &op->o_req_ndn, &e, &matched ); |
| 38 |
if ( e == NULL ) { |
| 39 |
rs->sr_err = LDAP_NO_SUCH_OBJECT; |
| 40 |
if ( matched ) { |
| 41 |
if ( !access_allowed_mask( op, matched, |
| 42 |
slap_schema.si_ad_entry, |
| 43 |
NULL, ACL_DISCLOSE, NULL, NULL ) ) |
| 44 |
{ |
| 45 |
/* do nothing */ ; |
| 46 |
} else { |
| 47 |
rs->sr_matched = matched->e_dn; |
| 48 |
} |
| 49 |
} |
| 50 |
send_ldap_result( op, rs ); |
| 51 |
if ( matched ) { |
| 52 |
monitor_cache_release( mi, matched ); |
| 53 |
rs->sr_matched = NULL; |
| 54 |
} |
| 55 |
|
| 56 |
return rs->sr_err; |
| 57 |
} |
| 58 |
|
| 59 |
monitor_entry_update( op, rs, e ); |
| 60 |
rs->sr_err = slap_compare_entry( op, e, op->orc_ava ); |
| 61 |
rc = rs->sr_err; |
| 62 |
switch ( rc ) { |
| 63 |
case LDAP_COMPARE_FALSE: |
| 64 |
case LDAP_COMPARE_TRUE: |
| 65 |
rc = LDAP_SUCCESS; |
| 66 |
break; |
| 67 |
} |
| 68 |
|
| 69 |
send_ldap_result( op, rs ); |
| 70 |
rs->sr_err = rc; |
| 71 |
|
| 72 |
monitor_cache_release( mi, e ); |
| 73 |
|
| 74 |
return rs->sr_err; |
| 75 |
} |
| 76 |
|