/*
- * Copyright 1998-2001 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*
* Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
Backend *be,
Connection *conn,
Operation *op,
- const char *dn,
- const char *ndn,
+ struct berval *dn,
+ struct berval *ndn,
AttributeAssertion *ava
)
{
struct metaconn *lc;
struct metasingleconn **lsc;
char *match = NULL, *err = NULL, *mmatch = NULL;
- int candidates = 0, last = 0, i, count, rc, cres, rres;
+ int candidates = 0, last = 0, i, count, rc;
+ int cres = LDAP_SUCCESS, rres = LDAP_SUCCESS;
int *msgid;
lc = meta_back_getconn( li, conn, op, META_OP_ALLOW_MULTIPLE,
*/
for ( i = 0, lsc = lc->conns; lsc[ 0 ] != NULL; ++i, ++lsc ) {
char *mdn = NULL;
- char *mapped_attr = ava->aa_desc->ad_cname->bv_val;
- char *mapped_value = ava->aa_value->bv_val;
+ struct berval mapped_attr = ava->aa_desc->ad_cname;
+ struct berval mapped_value = ava->aa_value;
if ( lsc[ 0 ]->candidate != META_CANDIDATE ) {
continue;
* Rewrite the compare dn, if needed
*/
switch ( rewrite_session( li->targets[ i ]->rwinfo,
- "compareDn", dn, conn, &mdn ) ) {
+ "compareDn",
+ dn->bv_val, conn, &mdn ) ) {
case REWRITE_REGEXEC_OK:
if ( mdn == NULL ) {
- mdn = ( char * )dn;
+ 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, mdn, "" );
+ dn->bv_val, mdn, "" );
+#endif /* !NEW_LOGGING */
break;
case REWRITE_REGEXEC_UNWILLING:
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
NULL, "Unwilling to perform",
NULL, NULL );
+ return -1;
case REWRITE_REGEXEC_ERR:
+ send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ NULL, "Operations error",
+ NULL, NULL );
return -1;
}
*/
if ( ava->aa_desc->ad_type->sat_oid
== slap_schema.si_ad_objectClass->ad_type->sat_oid ) {
- mapped_value = ldap_back_map( &li->targets[ i ]->oc_map,
- ava->aa_value->bv_val, 0 );
+ ldap_back_map( &li->targets[ i ]->oc_map,
+ &ava->aa_value, &mapped_value, 0 );
- if ( mapped_value == NULL ) {
+ if ( mapped_value.bv_val == NULL ) {
lsc[ 0 ]->candidate = META_NOT_CANDIDATE;
continue;
}
* else try to remap the attribute
*/
} else {
- mapped_attr = ldap_back_map( &li->targets[ i ]->at_map,
- ava->aa_desc->ad_cname->bv_val, 0 );
- if ( mapped_attr == NULL ) {
+ ldap_back_map( &li->targets[ i ]->at_map,
+ &ava->aa_desc->ad_cname, &mapped_attr, 0 );
+ if ( mapped_attr.bv_val == NULL ) {
lsc[ 0 ]->candidate = META_NOT_CANDIDATE;
continue;
}
* of the result ought to be enforced
*/
msgid[ i ] = ldap_compare( lc->conns[ i ]->ld, mdn,
- mapped_attr, mapped_value );
+ mapped_attr.bv_val, mapped_value.bv_val );
if ( msgid[ i ] == -1 ) {
lsc[ 0 ]->candidate = META_NOT_CANDIDATE;
continue;
}
- if ( mdn != dn ) {
+ if ( mdn != dn->bv_val ) {
free( mdn );
}
- if ( mapped_attr != ava->aa_desc->ad_cname->bv_val ) {
- free( mapped_attr );
+ if ( mapped_attr.bv_val != ava->aa_desc->ad_cname.bv_val ) {
+ free( mapped_attr.bv_val );
}
- if ( mapped_value != ava->aa_value->bv_val ) {
- free( mapped_value );
+ if ( mapped_value.bv_val != ava->aa_value.bv_val ) {
+ free( mapped_value.bv_val );
}
++candidates;
* sending to cache ...
*/
if ( li->cache.ttl != META_DNCACHE_DISABLED ) {
- ( void )meta_dncache_update_entry( &li->cache, ch_strdup( ndn ), i );
+ ( void )meta_dncache_update_entry( &li->cache, ndn, i );
}
count++;
}
}
-finish:
+finish:;
/*
* Rewrite the matched portion of the search base, if required
if ( mmatch == NULL ) {
mmatch = ( char * )match;
}
+#ifdef NEW_LOGGING
+ LDAP_LOG( BACK_META, DETAIL1,
+ "[rw] matchedDn: \"%s\" -> \"%s\"\n", match, mmatch, 0 );
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS, "rw> matchedDn:"
" \"%s\" -> \"%s\"\n%s",
match, mmatch, "" );
+#endif /* !NEW_LOGGING */
break;
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
NULL, "Unwilling to perform",
NULL, NULL );
- /* continue to the next case */
+ rc = -1;
+ goto cleanup;
case REWRITE_REGEXEC_ERR:
+ send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ NULL, "Operations error",
+ NULL, NULL );
rc = -1;
- break;
+ goto cleanup;
}
- }
+ }
+
send_ldap_result( conn, op, rres, mmatch, err, NULL, NULL );
+cleanup:;
if ( match != NULL ) {
if ( mmatch != match ) {
free( mmatch );