]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/compare.c
ITS#2368 - fix deleting key from range IDL
[openldap] / servers / slapd / compare.c
index c1f3db3f9ca161ae8663fbf8371d9af86cd7ea6c..bca36de6faacf06c6e609b333fecd34aa80020b9 100644 (file)
  */
 
 #include "portable.h"
-#include "slapi_common.h"
 
 #include <stdio.h>
 #include <ac/socket.h>
 
 #include "ldap_pvt.h"
 #include "slap.h"
+#ifdef LDAP_SLAPI
 #include "slapi.h"
+#endif
 
 static int compare_entry(
        Connection *conn,
@@ -50,7 +51,9 @@ do_compare(
        const char *text = NULL;
        int manageDSAit;
 
+#ifdef LDAP_SLAPI
        Slapi_PBlock *pb = op->o_pb;
+#endif
 
        ava.aa_desc = NULL;
 
@@ -140,8 +143,15 @@ do_compare(
                goto cleanup;
        }
 
+#ifdef SLAP_NVALUES
+       rc = asserted_value_validate_normalize( ava.aa_desc,
+               ava.aa_desc->ad_type->sat_equality,
+               SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
+               &value, &ava.aa_value, &text );
+#else
        rc = value_validate_normalize( ava.aa_desc, SLAP_MR_EQUALITY,
                &value, &ava.aa_value, &text );
+#endif
        if( rc != LDAP_SUCCESS ) {
                send_ldap_result( conn, op, rc, NULL, text, NULL, NULL );
                goto cleanup;
@@ -267,34 +277,31 @@ do_compare(
            op->o_connid, op->o_opid, pdn.bv_val,
                ava.aa_desc->ad_cname.bv_val, 0 );
 
-
-       /* deref suffix alias if appropriate */
-       suffix_alias( be, &ndn );
-
 #if defined( LDAP_SLAPI )
-       slapi_backend_set_pb( pb, be );
-       slapi_connection_set_pb( pb, conn );
-       slapi_operation_set_pb( pb, op );
+       slapi_x_backend_set_pb( pb, be );
+       slapi_x_connection_set_pb( pb, conn );
+       slapi_x_operation_set_pb( pb, op );
        slapi_pblock_set( pb, SLAPI_COMPARE_TARGET, (void *)dn.bv_val );
-       slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
+       slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
        slapi_pblock_set( pb, SLAPI_COMPARE_TYPE, (void *)desc.bv_val );
        slapi_pblock_set( pb, SLAPI_COMPARE_VALUE, (void *)&value );
 
        rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_COMPARE_FN, pb );
-       if ( rc != 0 && rc != LDAP_OTHER ) {
+       if ( rc != 0 ) {
                /*
-                * either there is no preOp (compare) plugins
-                * or a plugin failed. Just log it
-                *
-                * FIXME: is this correct?
+                * A preoperation plugin failure will abort the
+                * entire operation.
                 */
 #ifdef NEW_LOGGING
-               LDAP_LOG( OPERATION, INFO, "do_compare: compare preOps "
+               LDAP_LOG( OPERATION, INFO, "do_compare: compare preoperation plugin "
                                "failed\n", 0, 0, 0);
 #else
-               Debug(LDAP_DEBUG_TRACE, "do_compare: compare preOps "
+               Debug(LDAP_DEBUG_TRACE, "do_compare: compare preoperation plugin "
                                "failed.\n", 0, 0, 0);
 #endif
+               if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0)
+                       rc = LDAP_OTHER;
+               goto cleanup;
        }
 #endif /* defined( LDAP_SLAPI ) */
 
@@ -307,19 +314,12 @@ do_compare(
        }
 
 #if defined( LDAP_SLAPI )
-       rc = doPluginFNs( be, SLAPI_PLUGIN_POST_COMPARE_FN, pb );
-       if ( rc != 0 && rc != LDAP_OTHER ) {
-               /*
-                * either there is no postOp (compare) plugins
-                * or a plugin failed. Just log it
-                *
-                * FIXME: is this correct?
-                */
+       if ( doPluginFNs( be, SLAPI_PLUGIN_POST_COMPARE_FN, pb ) != 0 ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG( OPERATION, INFO, "do_compare: compare postOps "
+               LDAP_LOG( OPERATION, INFO, "do_compare: compare postoperation plugins "
                                "failed\n", 0, 0, 0 );
 #else
-               Debug(LDAP_DEBUG_TRACE, "do_compare: compare postOps "
+               Debug(LDAP_DEBUG_TRACE, "do_compare: compare postoperation plugins "
                                "failed.\n", 0, 0, 0);
 #endif
        }
@@ -354,7 +354,15 @@ static int compare_entry(
        {
                rc = LDAP_COMPARE_FALSE;
 
-               if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) {
+#ifdef SLAP_NVALUES
+               if ( value_find_ex( ava->aa_desc,
+                       SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
+                       a->a_nvals ? a->a_nvals : a->a_vals,
+                       &ava->aa_value ) == 0 )
+#else
+               if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 )
+#endif
+               {
                        rc = LDAP_COMPARE_TRUE;
                        break;
                }