]> git.sur5r.net Git - openldap/commitdiff
allow to compare on hasSubordinates
authorPierangelo Masarati <ando@openldap.org>
Sat, 31 Jul 2004 10:42:28 +0000 (10:42 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 31 Jul 2004 10:42:28 +0000 (10:42 +0000)
servers/slapd/compare.c

index 6680c43e4885ba00170d2383f1638cf9abf02991..cc55d1da54da6c6e4ee86501a2d77989b8079168 100644 (file)
@@ -321,9 +321,42 @@ fe_op_compare( Operation *op, SlapReply *rs )
        }
 #endif /* defined( LDAP_SLAPI ) */
 
-       if ( op->o_bd->be_compare ) {
-               op->orc_ava = &ava;
+       op->orc_ava = &ava;
+       if ( ava.aa_desc == slap_schema.si_ad_hasSubordinates
+                       && op->o_bd->be_has_subordinates )
+       {
+               int     rc, hasSubordinates = LDAP_SUCCESS;
+
+               rc = be_entry_get_rw( op, &op->o_req_ndn, NULL, NULL,
+                               0, &entry );
+               if ( rc == 0 && entry ) {
+                       rc = op->o_bd->be_has_subordinates( op, entry,
+                                       &hasSubordinates );
+                       be_entry_release_r( op, entry );
+               }
+
+               if ( rc == 0 ) {
+                       int     asserted;
+
+                       asserted = bvmatch( &ava.aa_value, &slap_true_bv )
+                               ? LDAP_COMPARE_TRUE : LDAP_COMPARE_FALSE;
+                       if ( hasSubordinates == asserted ) {
+                               rs->sr_err = LDAP_COMPARE_TRUE;
+                       } else {
+                               rs->sr_err = LDAP_COMPARE_FALSE;
+                       }
+               }
+               send_ldap_result( op, rs );
+
+               if ( rs->sr_err == LDAP_COMPARE_TRUE ||
+                               rs->sr_err == LDAP_COMPARE_FALSE )
+               {
+                       rs->sr_err = LDAP_SUCCESS;
+               }
+       
+       } else if ( op->o_bd->be_compare ) {
                op->o_bd->be_compare( op, rs );
+
        } else {
                send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
                        "operation not supported within namingContext" );