From: Pierangelo Masarati Date: Sat, 31 Jul 2004 10:42:28 +0000 (+0000) Subject: allow to compare on hasSubordinates X-Git-Tag: OPENDLAP_REL_ENG_2_2_MP~7 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=559397c44a95609ea50a38d64a206aaa9cdd2969;p=openldap allow to compare on hasSubordinates --- diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 6680c43e48..cc55d1da54 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -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" );