Back to index

openldap  2.4.31
compare.c
Go to the documentation of this file.
00001 /* compare.c - monitor backend compare routine */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 2001-2012 The OpenLDAP Foundation.
00006  * Portions Copyright 2001-2003 Pierangelo Masarati.
00007  * All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted only as authorized by the OpenLDAP
00011  * Public License.
00012  *
00013  * A copy of this license is available in file LICENSE in the
00014  * top-level directory of the distribution or, alternatively, at
00015  * <http://www.OpenLDAP.org/license.html>.
00016  */
00017 /* ACKNOWLEDGEMENTS:
00018  * This work was initially developed by Pierangelo Masarati for inclusion
00019  * in OpenLDAP Software.
00020  */
00021 
00022 #include "portable.h"
00023 
00024 #include <stdio.h>
00025 
00026 #include <slap.h>
00027 #include "back-monitor.h"
00028 
00029 int
00030 monitor_back_compare( Operation *op, SlapReply *rs )
00031 {
00032        monitor_info_t       *mi = ( monitor_info_t * ) op->o_bd->be_private;
00033        Entry           *e, *matched = NULL;
00034        int           rc;
00035 
00036        /* get entry with reader lock */
00037        monitor_cache_dn2entry( op, rs, &op->o_req_ndn, &e, &matched );
00038        if ( e == NULL ) {
00039               rs->sr_err = LDAP_NO_SUCH_OBJECT;
00040               if ( matched ) {
00041                      if ( !access_allowed_mask( op, matched,
00042                                    slap_schema.si_ad_entry,
00043                                    NULL, ACL_DISCLOSE, NULL, NULL ) )
00044                      {
00045                             /* do nothing */ ;
00046                      } else {
00047                             rs->sr_matched = matched->e_dn;
00048                      }
00049               }
00050               send_ldap_result( op, rs );
00051               if ( matched ) {
00052                      monitor_cache_release( mi, matched );
00053                      rs->sr_matched = NULL;
00054               }
00055 
00056               return rs->sr_err;
00057        }
00058 
00059        monitor_entry_update( op, rs, e );
00060        rs->sr_err = slap_compare_entry( op, e, op->orc_ava );
00061        rc = rs->sr_err;
00062        switch ( rc ) {
00063        case LDAP_COMPARE_FALSE:
00064        case LDAP_COMPARE_TRUE:
00065               rc = LDAP_SUCCESS;
00066               break;
00067        }
00068               
00069        send_ldap_result( op, rs );
00070        rs->sr_err = rc;
00071 
00072        monitor_cache_release( mi, e );
00073 
00074        return rs->sr_err;
00075 }
00076