]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/compare.c
Use "uri" directive (instead of "server") to specify server. Add "bin
[openldap] / servers / slapd / compare.c
index 259698bc46e623dda92d377bfa1c8e7a87ebbb1f..c25958b01b044ecce24824b97a741dddad2c2b3b 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 /*
@@ -33,30 +33,21 @@ do_compare(
        char    *dn = NULL, *ndn=NULL;
        struct berval desc;
        struct berval value;
-       Backend *be;
-       int rc = LDAP_SUCCESS;
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
-       char *text = NULL;
+       struct berval *nvalue;
        AttributeAssertion ava;
-
-       ava.aa_desc = NULL;
 #else
        Ava     ava;
 #endif
+       Backend *be;
+       int rc = LDAP_SUCCESS;
+       const char *text = NULL;
 
        desc.bv_val = NULL;
        value.bv_val = NULL;
 
        Debug( LDAP_DEBUG_TRACE, "do_compare\n", 0, 0, 0 );
 
-       if( op->o_bind_in_progress ) {
-               Debug( LDAP_DEBUG_ANY, "do_compare: SASL bind in progress.\n",
-                       0, 0, 0 );
-               send_ldap_result( conn, op, LDAP_SASL_BIND_IN_PROGRESS,
-                       NULL, "SASL bind in progress", NULL, NULL );
-               return LDAP_SASL_BIND_IN_PROGRESS;
-       }
-
        /*
         * Parse the compare request.  It looks like this:
         *
@@ -107,13 +98,30 @@ do_compare(
        }
 
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
+       ava.aa_desc = NULL;
        rc = slap_bv2ad( &desc, &ava.aa_desc, &text );
        if( rc != LDAP_SUCCESS ) {
                send_ldap_result( conn, op, rc, NULL,
                    text, NULL, NULL );
                goto cleanup;
        }
-       ava.aa_value = &value;
+
+       if( !ava.aa_desc->ad_type->sat_equality ) {
+               /* no equality matching rule */
+               send_ldap_result( conn, op, rc = LDAP_INAPPROPRIATE_MATCHING, NULL,
+                   "no equality matching rule defined", NULL, NULL );
+               goto cleanup;
+       }
+
+       rc = value_normalize( ava.aa_desc, SLAP_MR_EQUALITY, &value, &nvalue, &text );
+
+       if( rc != LDAP_SUCCESS ) {
+               send_ldap_result( conn, op, rc, NULL,
+                   text, NULL, NULL );
+               goto cleanup;
+       }
+
+       ava.aa_value = nvalue;
 
        Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n",
            dn, ava.aa_desc->ad_cname, ava.aa_value->bv_val );
@@ -148,11 +156,11 @@ do_compare(
        }
 
        /* make sure this backend recongizes critical controls */
-       rc = backend_check_controls( be, conn, op ) ;
+       rc = backend_check_controls( be, conn, op, &text ) ;
 
        if( rc != LDAP_SUCCESS ) {
                send_ldap_result( conn, op, rc,
-                       NULL, NULL, NULL, NULL );
+                       NULL, text, NULL, NULL );
                goto cleanup;
        }
 
@@ -163,7 +171,7 @@ do_compare(
                (*be->be_compare)( be, conn, op, dn, ndn, &ava );
        } else {
                send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
-                       NULL, "Function not implemented", NULL, NULL );
+                       NULL, "operation not supported within namingContext", NULL, NULL );
        }
 
 cleanup: