- for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
- char *mdn = NULL;
- struct berval mapped_attr = ava->aa_desc->ad_cname;
- struct berval mapped_value = ava->aa_value;
-
- if ( lsc->candidate != META_CANDIDATE ) {
- msgid[ i ] = -1;
- continue;
- }
-
- /*
- * Rewrite the compare dn, if needed
- */
- switch ( rewrite_session( li->targets[ i ]->rwinfo,
- "compareDn",
- dn->bv_val, conn, &mdn ) ) {
- case REWRITE_REGEXEC_OK:
- if ( mdn == NULL ) {
- mdn = ( char * )dn->bv_val;
- }
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "[rw] compareDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn, 0 );
-#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS,
- "rw> compareDn: \"%s\" -> \"%s\"\n%s",
- dn->bv_val, mdn, "" );
-#endif /* !NEW_LOGGING */
- break;
-
- case REWRITE_REGEXEC_UNWILLING:
- send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
- NULL, "Operation not allowed",
- NULL, NULL );
- return -1;
-
- case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OTHER,
- NULL, "Rewrite error",
- NULL, NULL );
- return -1;
- }
-
- /*
- * if attr is objectClass, try to remap the value
- */
- if ( ava->aa_desc->ad_type->sat_oid
- == slap_schema.si_ad_objectClass->ad_type->sat_oid ) {
- ldap_back_map( &li->targets[ i ]->oc_map,
- &ava->aa_value, &mapped_value, 0 );
-
- if ( mapped_value.bv_val == NULL ) {
- continue;
- }
- /*
- * else try to remap the attribute
- */
- } else {
- ldap_back_map( &li->targets[ i ]->at_map,
- &ava->aa_desc->ad_cname, &mapped_attr, 0 );
- if ( mapped_attr.bv_val == NULL ) {
- continue;
- }
- }
-
- /*
- * the compare op is spawned across the targets and the first
- * that returns determines the result; a constraint on unicity
- * of the result ought to be enforced
- */
- msgid[ i ] = ldap_compare( lc->conns[ i ].ld, mdn,
- mapped_attr.bv_val, mapped_value.bv_val );
- if ( mdn != dn->bv_val ) {
- free( mdn );
- }
- if ( mapped_attr.bv_val != ava->aa_desc->ad_cname.bv_val ) {
- free( mapped_attr.bv_val );
- }
- if ( mapped_value.bv_val != ava->aa_value.bv_val ) {
- free( mapped_value.bv_val );
- }
-
- if ( msgid[ i ] == -1 ) {
- continue;
- }
-
- ++candidates;