Attribute *a;
LDAPMod **attrs;
struct berval mdn = { 0, NULL }, mapped;
+ dncookie dc;
#ifdef NEW_LOGGING
LDAP_LOG( BACK_META, ENTRY, "meta_back_add: %s\n",
/*
* Rewrite the add dn, if needed
*/
- switch ( rewrite_session( li->targets[ candidate ]->rwinfo,
- "addDn", op->o_req_dn.bv_val, op->o_conn,
- &mdn.bv_val ) ) {
- case REWRITE_REGEXEC_OK:
- if ( mdn.bv_val != NULL && mdn.bv_val[ 0 ] != '\0' ) {
- mdn.bv_len = strlen( mdn.bv_val );
- } else {
- mdn = op->o_req_dn;
- }
+ dc.rwmap = &li->targets[ candidate ]->rwmap;
+ dc.conn = op->o_conn;
+ dc.rs = rs;
+ dc.ctx = "addDn";
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "[rw] addDn: \"%s\" -> \"%s\"\n",
- op->o_req_dn.bv_val, mdn.bv_val, 0 );
-#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS, "rw> addDn: \"%s\" -> \"%s\"\n",
- op->o_req_dn.bv_val, mdn.bv_val, 0 );
-#endif /* !NEW_LOGGING */
- break;
-
- case REWRITE_REGEXEC_UNWILLING:
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
- rs->sr_text = "Operation not allowed";
- send_ldap_result( op, rs );
- return -1;
-
- case REWRITE_REGEXEC_ERR:
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "Rewrite error";
- send_ldap_result( op, rs );
+ if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
+ send_ldap_result( op, rs );
return -1;
}
continue;
}
- ldap_back_map( &li->targets[ candidate ]->at_map,
+ ldap_back_map( &li->targets[ candidate ]->rwmap.rwm_at,
&a->a_desc->ad_cname, &mapped, BACKLDAP_MAP );
if ( mapped.bv_val == NULL || mapped.bv_val[0] == '\0' ) {
continue;
*/
if ( strcmp( a->a_desc->ad_type->sat_syntax->ssyn_oid,
SLAPD_DN_SYNTAX ) == 0 ) {
- ldap_dnattr_rewrite( li->targets[ candidate ]->rwinfo,
- a->a_vals, op->o_conn );
+ (void)ldap_dnattr_rewrite( &dc, a->a_vals );
}
for ( j = 0; a->a_vals[ j ].bv_val; j++ );
struct berval pseudorootdn;
struct berval pseudorootpw;
+#if 0
struct rewrite_info *rwinfo;
struct ldapmap oc_map;
struct ldapmap at_map;
+#endif
+ struct ldaprwmap rwmap;
};
struct metadncache {
struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
struct berval mdn = { 0, NULL };
ber_int_t msgid;
+ dncookie dc;
/*
* Rewrite the bind dn if needed
*/
- switch ( rewrite_session( li->targets[ candidate ]->rwinfo,
- "bindDn", op->o_req_dn.bv_val,
- lc->conn, &mdn.bv_val ) ) {
- case REWRITE_REGEXEC_OK:
- if ( mdn.bv_val == NULL ) {
- mdn = op->o_req_dn;
- } else {
- mdn.bv_len = strlen( mdn.bv_val );
- }
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "[rw] bindDn: \"%s\" -> \"%s\"\n",
- op->o_req_dn.bv_val, mdn.bv_val, 0 );
-#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS,
- "rw> bindDn: \"%s\" -> \"%s\"\n%s",
- op->o_req_dn.bv_val, mdn.bv_val, "" );
-#endif /* !NEW_LOGGING */
- break;
-
- case REWRITE_REGEXEC_UNWILLING:
- return LDAP_UNWILLING_TO_PERFORM;
+ dc.rwmap = &li->targets[ candidate ]->rwmap;
+ dc.conn = op->o_conn;
+ dc.rs = rs;
+ dc.ctx = "bindDn";
- case REWRITE_REGEXEC_ERR:
- return LDAP_OTHER;
+ if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
+ send_ldap_result( op, rs );
+ return -1;
}
if ( op->o_ctrls ) {
struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
struct metaconn *lc;
struct metasingleconn *lsc;
- char *match = NULL, *err = NULL, *mmatch = NULL;
+ char *match = NULL, *err = NULL;
+ struct berval mmatch = { 0, NULL };
int candidates = 0, last = 0, i, count, rc;
int cres = LDAP_SUCCESS, rres = LDAP_SUCCESS;
int *msgid;
+ dncookie dc;
lc = meta_back_getconn( op, rs, META_OP_ALLOW_MULTIPLE,
&op->o_req_ndn, NULL );
/*
* start an asynchronous compare for each candidate target
*/
+ dc.conn = op->o_conn;
+ dc.rs = rs;
+ dc.ctx = "compareDn";
+
for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
- char *mdn = NULL;
+ struct berval mdn = { 0, NULL };
struct berval mapped_attr = op->oq_compare.rs_ava->aa_desc->ad_cname;
struct berval mapped_value = op->oq_compare.rs_ava->aa_value;
/*
* Rewrite the compare dn, if needed
*/
- switch ( rewrite_session( li->targets[ i ]->rwinfo,
- "compareDn",
- op->o_req_dn.bv_val, op->o_conn, &mdn ) ) {
- case REWRITE_REGEXEC_OK:
- if ( mdn == NULL ) {
- mdn = ( char * )op->o_req_dn.bv_val;
- }
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "[rw] compareDn: \"%s\" -> \"%s\"\n",
- op->o_req_dn.bv_val, mdn, 0 );
-#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS,
- "rw> compareDn: \"%s\" -> \"%s\"\n",
- op->o_req_dn.bv_val, mdn, 0 );
-#endif /* !NEW_LOGGING */
+ dc.rwmap = &li->targets[ i ]->rwmap;
+
+ switch ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
+ case LDAP_UNWILLING_TO_PERFORM:
+ rc = 1;
+ goto finish;
+
+ default:
break;
-
- case REWRITE_REGEXEC_UNWILLING:
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
- rs->sr_text = "Operation not allowed";
- send_ldap_result( op, rs );
- return -1;
-
- case REWRITE_REGEXEC_ERR:
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "Rewrite error";
- send_ldap_result( op, rs );
- return -1;
}
/*
* if attr is objectClass, try to remap the value
*/
if ( op->oq_compare.rs_ava->aa_desc == slap_schema.si_ad_objectClass ) {
- ldap_back_map( &li->targets[ i ]->oc_map,
+ ldap_back_map( &li->targets[ i ]->rwmap.rwm_oc,
&op->oq_compare.rs_ava->aa_value,
&mapped_value, BACKLDAP_MAP );
* else try to remap the attribute
*/
} else {
- ldap_back_map( &li->targets[ i ]->at_map,
+ ldap_back_map( &li->targets[ i ]->rwmap.rwm_at,
&op->oq_compare.rs_ava->aa_desc->ad_cname,
&mapped_attr, BACKLDAP_MAP );
if ( mapped_attr.bv_val == NULL || mapped_attr.bv_val[0] == '\0' ) {
* 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,
+ msgid[ i ] = ldap_compare( lc->conns[ i ].ld, mdn.bv_val,
mapped_attr.bv_val, mapped_value.bv_val );
- if ( mdn != op->o_req_dn.bv_val ) {
- free( mdn );
+ if ( mdn.bv_val != op->o_req_dn.bv_val ) {
+ free( mdn.bv_val );
+ mdn.bv_val = NULL;
}
if ( mapped_attr.bv_val != op->oq_compare.rs_ava->aa_desc->ad_cname.bv_val ) {
free( mapped_attr.bv_val );
*/
rres = cres;
- } else if ( match != NULL ) {
-
/*
* At least one compare failed with matched portion,
* and none was successful
*/
- switch ( rewrite_session( li->targets[ last ]->rwinfo,
- "matchedDn", match, op->o_conn,
- &mmatch ) ) {
- case REWRITE_REGEXEC_OK:
- 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",
- match, mmatch, 0 );
-#endif /* !NEW_LOGGING */
- break;
-
-
- case REWRITE_REGEXEC_UNWILLING:
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
- rs->sr_text = "Operation not allowed";
- send_ldap_result( op, rs );
- rc = -1;
- goto cleanup;
-
- case REWRITE_REGEXEC_ERR:
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "Rewrite error";
- send_ldap_result( op, rs );
- rc = -1;
- goto cleanup;
- }
+ } else if ( match != NULL && match[0] != '\0' ) {
+ struct berval matched;
+
+ matched.bv_val = match;
+ matched.bv_len = strlen( match );
+
+ dc.ctx = "matchedDn";
+ ldap_back_dn_massage( &dc, &matched, &mmatch );
}
rs->sr_err = rres;
- rs->sr_matched = mmatch;
+ rs->sr_matched = mmatch.bv_val;
send_ldap_result( op, rs );
rs->sr_matched = NULL;
-cleanup:;
if ( match != NULL ) {
- if ( mmatch != match ) {
- free( mmatch );
+ if ( mmatch.bv_val != match ) {
+ free( mmatch.bv_val );
}
free( match );
}
return NULL;
}
- lt->rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
- if ( lt->rwinfo == NULL ) {
+ lt->rwmap.rwm_rw = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
+ if ( lt->rwmap.rwm_rw == NULL ) {
free( lt );
return NULL;
}
- ldap_back_map_init( <->at_map, &mapping );
+ ldap_back_map_init( <->rwmap.rwm_at, &mapping );
return lt;
}
* FIXME: no extra rewrite capabilities should be added
* to the database
*/
- return suffix_massage_config( li->targets[ i ]->rwinfo,
+ return suffix_massage_config( li->targets[ i ]->rwmap.rwm_rw,
&pvnc, &nvnc, &prnc, &nrnc );
/* rewrite stuff ... */
#endif /* LDAP_CACHING */
}
- return rewrite_parse( li->targets[ i ]->rwinfo, fname, lineno,
+ return rewrite_parse( li->targets[ i ]->rwmap.rwm_rw, fname, lineno,
argc, argv );
/* objectclass/attribute mapping */
return 1;
}
- return ldap_back_map_config( &li->targets[ i ]->oc_map,
- &li->targets[ i ]->at_map,
+ return ldap_back_map_config( &li->targets[ i ]->rwmap.rwm_oc,
+ &li->targets[ i ]->rwmap.rwm_at,
fname, lineno, argc, argv );
/* anything else */
} else {
/*
* Sets a cookie for the rewrite session
*/
- ( void )rewrite_session_init( lt->rwinfo, op->o_conn );
+ ( void )rewrite_session_init( lt->rwmap.rwm_rw, op->o_conn );
/*
* If the connection dn is not null, an attempt to rewrite it is made
* Rewrite the bind dn if needed
*/
lsc->bound_dn.bv_val = NULL;
- switch ( rewrite_session( lt->rwinfo, "bindDn",
+ switch ( rewrite_session( lt->rwmap.rwm_rw, "bindDn",
op->o_conn->c_dn.bv_val, op->o_conn,
&lsc->bound_dn.bv_val ) ) {
case REWRITE_REGEXEC_OK:
struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
struct metaconn *lc;
int candidate = -1;
-
- char *mdn = NULL;
+ struct berval mdn = { 0, NULL };
+ dncookie dc;
lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE,
&op->o_req_ndn, &candidate );
/*
* Rewrite the compare dn, if needed
*/
- switch ( rewrite_session( li->targets[ candidate ]->rwinfo,
- "deleteDn", op->o_req_dn.bv_val,
- op->o_conn, &mdn ) ) {
- case REWRITE_REGEXEC_OK:
- if ( mdn == NULL ) {
- mdn = ( char * )op->o_req_dn.bv_val;
- }
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "[rw] deleteDn: \"%s\" -> \"%s\"\n",
- op->o_req_dn.bv_val, mdn, 0 );
-#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS, "rw> deleteDn: \"%s\" -> \"%s\"\n",
- op->o_req_dn.bv_val, mdn, 0 );
-#endif /* !NEW_LOGGING */
- break;
-
- case REWRITE_REGEXEC_UNWILLING:
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
- rs->sr_text = "Operation not allowed";
- send_ldap_result( op, rs );
- return -1;
+ dc.rwmap = &li->targets[ candidate ]->rwmap;
+ dc.conn = op->o_conn;
+ dc.rs = rs;
+ dc.ctx = "deleteDn";
- case REWRITE_REGEXEC_ERR:
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "Rewrite error";
+ if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
send_ldap_result( op, rs );
return -1;
}
-
- ldap_delete_s( lc->conns[ candidate ].ld, mdn );
- if ( mdn != op->o_req_dn.bv_val ) {
- free( mdn );
+ ldap_delete_s( lc->conns[ candidate ].ld, mdn.bv_val );
+
+ if ( mdn.bv_val != op->o_req_dn.bv_val ) {
+ free( mdn.bv_val );
}
return meta_back_op_result( lc, op, rs );
if ( lt->pseudorootpw.bv_val ) {
free( lt->pseudorootpw.bv_val );
}
- if ( lt->rwinfo ) {
- rewrite_info_delete( lt->rwinfo );
+ if ( lt->rwmap.rwm_rw ) {
+ rewrite_info_delete( lt->rwmap.rwm_rw );
}
- avl_free( lt->oc_map.remap, NULL );
- avl_free( lt->oc_map.map, mapping_free );
- avl_free( lt->at_map.remap, NULL );
- avl_free( lt->at_map.map, mapping_free );
+ avl_free( lt->rwmap.rwm_oc.remap, NULL );
+ avl_free( lt->rwmap.rwm_oc.map, mapping_free );
+ avl_free( lt->rwmap.rwm_at.remap, NULL );
+ avl_free( lt->rwmap.rwm_at.map, mapping_free );
}
int
LDAPMod *mods = NULL;
Modifications *ml;
int candidate = -1, i;
- char *mdn;
+ struct berval mdn = { 0, NULL };
struct berval mapped;
+ dncookie dc;
lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE,
&op->o_req_ndn, &candidate );
/*
* Rewrite the modify dn, if needed
*/
- switch ( rewrite_session( li->targets[ candidate ]->rwinfo,
- "modifyDn", op->o_req_dn.bv_val,
- op->o_conn, &mdn ) ) {
- case REWRITE_REGEXEC_OK:
- if ( mdn == NULL ) {
- mdn = ( char * )op->o_req_dn.bv_val;
- }
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "[rw] modifyDn: \"%s\" -> \"%s\"\n",
- op->o_req_dn.bv_val, mdn, 0 );
-#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS, "rw> modifyDn: \"%s\" -> \"%s\"\n",
- op->o_req_dn.bv_val, mdn, 0 );
-#endif /* !NEW_LOGGING */
- break;
-
- case REWRITE_REGEXEC_UNWILLING:
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
- rs->sr_text = "Operation not allowed";
- rc = -1;
- goto cleanup;
+ dc.rwmap = &li->targets[ candidate ]->rwmap;
+ dc.conn = op->o_conn;
+ dc.rs = rs;
+ dc.ctx = "modifyDn";
- case REWRITE_REGEXEC_ERR:
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "Rewrite error";
+ if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
rc = -1;
goto cleanup;
}
goto cleanup;
}
+ dc.ctx = "modifyAttrDN";
for ( i = 0, ml = op->oq_modify.rs_modlist; ml; ml = ml->sml_next ) {
int j;
continue;
}
- ldap_back_map( &li->targets[ candidate ]->at_map,
+ ldap_back_map( &li->targets[ candidate ]->rwmap.rwm_at,
&ml->sml_desc->ad_cname, &mapped,
BACKLDAP_MAP );
if ( mapped.bv_val == NULL || mapped.bv_val[0] == '\0' ) {
*/
if ( strcmp( ml->sml_desc->ad_type->sat_syntax->ssyn_oid,
SLAPD_DN_SYNTAX ) == 0 ) {
- ldap_dnattr_rewrite(
- li->targets[ candidate ]->rwinfo,
- ml->sml_bvalues, op->o_conn );
+ ( void )ldap_dnattr_rewrite( &dc, ml->sml_bvalues );
}
if ( ml->sml_bvalues != NULL ){
}
modv[ i ] = 0;
- ldap_modify_s( lc->conns[ candidate ].ld, mdn, modv );
+ ldap_modify_s( lc->conns[ candidate ].ld, mdn.bv_val, modv );
cleanup:;
- if ( mdn != op->o_req_dn.bv_val ) {
- free( mdn );
+ if ( mdn.bv_val != op->o_req_dn.bv_val ) {
+ free( mdn.bv_val );
}
if ( modv != NULL ) {
for ( i = 0; modv[ i ]; i++) {
/*
* Rewrite the new superior, if defined and required
*/
- switch ( rewrite_session( li->targets[ nsCandidate ]->rwinfo,
+ switch ( rewrite_session( li->targets[ nsCandidate ]->rwmap.rwm_rw,
"newSuperiorDn",
op->oq_modrdn.rs_newSup->bv_val,
op->o_conn,
/*
* Rewrite the modrdn dn, if required
*/
- switch ( rewrite_session( li->targets[ candidate ]->rwinfo,
+ switch ( rewrite_session( li->targets[ candidate ]->rwmap.rwm_rw,
"modrDn", op->o_req_dn.bv_val,
op->o_conn, &mdn ) ) {
case REWRITE_REGEXEC_OK:
int i, last = 0, candidates = 0;
struct slap_limits_set *limit = NULL;
int isroot = 0;
+ dncookie dc;
#ifdef LDAP_CACHING
cache_manager* cm = li->cm;
/* negative hard limit means no limit */
}
+
+ dc.conn = op->o_conn;
+ dc.rs = rs;
+
/*
* Inits searches
*/
for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
- char *realbase = ( char * )op->o_req_dn.bv_val;
+ struct berval realbase = op->o_req_dn;
int realscope = op->oq_search.rs_scope;
ber_len_t suffixlen = 0;
- char *mbase = NULL;
- struct berval mfilter = { 0L, NULL };
+ struct berval mbase = { 0, NULL };
+ struct berval mfilter = { 0, NULL };
char **mapped_attrs = NULL;
if ( lsc->candidate != META_CANDIDATE ) {
( void * )&op->oq_search.rs_slimit);
}
+ dc.rwmap = &li->targets[ i ]->rwmap;
+
/*
* modifies the base according to the scope, if required
*/
*/
if ( dnIsSuffix( &li->targets[ i ]->suffix,
&op->o_req_ndn ) ) {
- realbase = li->targets[ i ]->suffix.bv_val;
+ realbase = li->targets[ i ]->suffix;
} else {
/*
* this target is no longer candidate
* make the target suffix the new
* base, and make scope "base"
*/
- realbase = li->targets[ i ]->suffix.bv_val;
+ realbase = li->targets[ i ]->suffix;
realscope = LDAP_SCOPE_BASE;
break;
} /* else continue with the next case */
/*
* Rewrite the search base, if required
*/
- switch ( rewrite_session( li->targets[ i ]->rwinfo,
- "searchBase",
- realbase, op->o_conn, &mbase ) ) {
- case REWRITE_REGEXEC_OK:
- if ( mbase == NULL ) {
- mbase = realbase;
- }
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "[rw] searchBase [%d]: \"%s\" -> \"%s\"\n",
- i, op->o_req_dn.bv_val, mbase );
-#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS,
- "rw> searchBase [%d]: \"%s\" -> \"%s\"\n",
- i, op->o_req_dn.bv_val, mbase );
-#endif /* !NEW_LOGGING */
- break;
-
+ dc.ctx = "searchBase";
+ switch ( ldap_back_dn_massage( &dc, &realbase, &mbase ) ) {
+ default:
+ break;
+
case REWRITE_REGEXEC_UNWILLING:
rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
rs->sr_text = "Operation not allowed";
/*
* Maps filter
*/
- rc = ldap_back_filter_map_rewrite_( li->targets[ i ]->rwinfo,
- op->o_conn,
- &li->targets[ i ]->at_map,
- &li->targets[ i ]->oc_map,
+ rc = ldap_back_filter_map_rewrite( &dc,
op->oq_search.rs_filter,
&mfilter, BACKLDAP_MAP );
if ( rc != 0 ) {
/*
* Maps required attributes
*/
- rc = ldap_back_map_attrs( &li->targets[ i ]->at_map,
+ rc = ldap_back_map_attrs( &li->targets[ i ]->rwmap.rwm_at,
op->oq_search.rs_attrs, BACKLDAP_MAP,
&mapped_attrs );
if ( rc != LDAP_SUCCESS ) {
goto new_candidate;
}
-#if 0
- if ( mapped_attrs == NULL && op->oq_search.rs_attrs) {
- int count;
- for ( count = 0; op->oq_search.rs_attrs[ count ].an_name.bv_val; count++ );
- mapped_attrs = ch_malloc( ( count + 1 ) * sizeof(char *));
- for ( count = 0; op->oq_search.rs_attrs[ count ].an_name.bv_val; count++ ) {
- mapped_attrs[ count ] = op->oq_search.rs_attrs[ count ].an_name.bv_val;
- }
- mapped_attrs[ count ] = NULL;
- }
-#endif
-
/*
* Starts the search
*/
- msgid[ i ] = ldap_search( lsc->ld, mbase, realscope,
+ msgid[ i ] = ldap_search( lsc->ld, mbase.bv_val, realscope,
mfilter.bv_val, mapped_attrs,
op->oq_search.rs_attrsonly );
if ( mapped_attrs ) {
free( mfilter.bv_val );
mfilter.bv_val = NULL;
}
- if ( mbase != realbase ) {
- free( mbase );
- mbase = NULL;
+ if ( mbase.bv_val != realbase.bv_val ) {
+ free( mbase.bv_val );
+ mbase.bv_val = NULL;
}
if ( msgid[ i ] == -1 ) {
* FIXME: only the last one gets caught!
*/
if ( match != NULL ) {
- switch ( rewrite_session( li->targets[ last ]->rwinfo,
+ switch ( rewrite_session( li->targets[ last ]->rwmap.rwm_rw,
"matchedDn", match, op->o_conn,
&mmatch ) ) {
case REWRITE_REGEXEC_OK:
struct berval dummy = { 0, NULL };
struct berval *bv, bdn;
const char *text;
+ dncookie dc;
if ( ber_scanf( &ber, "{m{", &bdn ) == LBER_ERROR ) {
return LDAP_DECODING_ERROR;
/*
* Rewrite the dn of the result, if needed
*/
- switch ( rewrite_session( li->targets[ target ]->rwinfo,
- "searchResult", bdn.bv_val, lc->conn,
- &ent.e_name.bv_val ) ) {
- case REWRITE_REGEXEC_OK:
- if ( ent.e_name.bv_val == NULL ) {
- ent.e_name = bdn;
-
- } else {
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "[rw] searchResult[%d]: \"%s\" -> \"%s\"\n",
- target, bdn.bv_val, ent.e_name.bv_val );
-#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS, "rw> searchResult[%d]: \"%s\""
- " -> \"%s\"\n", target, bdn.bv_val,
- ent.e_name.bv_val );
-#endif /* !NEW_LOGGING */
- ent.e_name.bv_len = strlen( ent.e_name.bv_val );
- }
- break;
-
- case REWRITE_REGEXEC_UNWILLING:
- return LDAP_UNWILLING_TO_PERFORM;
-
- case REWRITE_REGEXEC_ERR:
- return LDAP_OTHER;
+ dc.rwmap = &li->targets[ target ]->rwmap;
+ dc.conn = op->o_conn;
+ dc.rs = rs;
+ dc.ctx = "searchResult";
+
+ rs->sr_err = ldap_back_dn_massage( &dc, &bdn, &ent.e_name );
+ if ( rs->sr_err != LDAP_SUCCESS) {
+ return rs->sr_err;
}
/*
*/
if ( li->cache.ttl != META_DNCACHE_DISABLED ) {
( void )meta_dncache_update_entry( &li->cache,
- &ent.e_nname,
- target );
+ &ent.e_nname, target );
}
ent.e_id = 0;
attrp = &ent.e_attrs;
while ( ber_scanf( &ber, "{m", &a ) != LBER_ERROR ) {
- ldap_back_map( &li->targets[ target ]->at_map,
+ ldap_back_map( &li->targets[ target ]->rwmap.rwm_at,
&a, &mapped, BACKLDAP_REMAP );
if ( mapped.bv_val == NULL || mapped.bv_val[0] == '\0' ) {
continue;
for ( last = 0; attr->a_vals[ last ].bv_val; ++last );
for ( bv = attr->a_vals; bv->bv_val; bv++ ) {
- ldap_back_map( &li->targets[ target]->oc_map,
+ ldap_back_map( &li->targets[ target ]->rwmap.rwm_oc,
bv, &mapped, BACKLDAP_REMAP );
if ( mapped.bv_val == NULL || mapped.bv_val[0] == '\0') {
free( bv->bv_val );
for ( bv = attr->a_vals; bv->bv_val; bv++ ) {
char *newval;
- switch ( rewrite_session( li->targets[ target ]->rwinfo,
+ switch ( rewrite_session( li->targets[ target ]->rwmap.rwm_rw,
"searchResult",
bv->bv_val,
lc->conn, &newval )) {
continue;
}
- rewrite_session_delete( li->targets[ i ]->rwinfo, conn );
+ rewrite_session_delete( li->targets[ i ]->rwmap.rwm_rw, conn );
meta_clear_one_candidate( &lc->conns[ i ], 1 );
}