LDAPMod **attrs;
char *mdn = NULL, *mapped;
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, "meta_back_add: %s\n",
+ e->e_dn ));
+#else /* !NEW_LOGGING */
+ Debug(LDAP_DEBUG_ARGS, "==> meta_back_add: %s\n", e->e_dn, 0, 0);
+#endif /* !NEW_LOGGING */
+
/*
* get the current connection
*/
if ( mdn == NULL ) {
mdn = e->e_dn;
}
+
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] addDn: \"%s\" -> \"%s\"\n",
+ e->e_dn, mdn ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS, "rw> addDn: \"%s\" -> \"%s\"\n%s",
e->e_dn, 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;
}
extern int
meta_back_do_single_bind(
- Operation *op,
struct metainfo *li,
struct metaconn *lc,
const char *dn,
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
- "meta_back_bind: dn: %s.\n", dn ));
+ "meta_back_bind: dn: %s.\n", dn ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS, "meta_back_bind: dn: %s.\n%s%s", dn, "", "" );
#endif /* !NEW_LOGGING */
if ( !lc ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_NOTICE,
- "meta_back_bind: no target for dn %s.\n", dn ));
+ "meta_back_bind: no target for dn %s.\n",
+ dn ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ANY,
"meta_back_bind: no target for dn %s.\n%s%s",
*/
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_WARNING,
-"==>meta_back_bind: more that one candidate is attempting to bind ...%s%s%s\n" ));
+ "==>meta_back_bind: more than one"
+ " candidate is attempting to bind"
+ " ...\n" ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ANY,
-"==>meta_back_bind: more that one candidate is attempting to bind ...%s%s%s\n",
- "", "", "" );
+ "==>meta_back_bind: more than one"
+ " candidate is attempting to bind"
+ " ...\n%s%s%s",
+ "", "", "" );
#endif /* !NEW_LOGGING */
}
- lerr = meta_back_do_single_bind( op, li, lc, dn, ndn, cred,
+ lerr = meta_back_do_single_bind( li, lc, dn, ndn, cred,
method, i );
if ( lerr != LDAP_SUCCESS ) {
err = lerr;
*/
int
meta_back_do_single_bind(
- Operation *op,
struct metainfo *li,
struct metaconn *lc,
const char *dn,
if ( mdn == NULL ) {
mdn = ( char * )dn;
}
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] bindDn: \"%s\" -> \"%s\"\n", dn, mdn ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> bindDn: \"%s\" -> \"%s\"\n%s",
dn, mdn, "" );
+#endif /* !NEW_LOGGING */
break;
case REWRITE_REGEXEC_UNWILLING:
- send_ldap_result( lc->conn, op, LDAP_UNWILLING_TO_PERFORM,
- NULL, "Unwilling to perform",
- NULL, NULL );
- /* continues to next case */
+ return LDAP_UNWILLING_TO_PERFORM;
case REWRITE_REGEXEC_ERR:
- return -1;
+ return LDAP_OPERATIONS_ERROR;
}
rc = ldap_bind_s( lc->conns[ candidate ]->ld, mdn,
NULL, LDAP_AUTH_SIMPLE );
if ( rc != LDAP_SUCCESS ) {
- /*
- * This way, the first bind error would be fatal ...
- */
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_WARNING,
+ "meta_back_dobind: (anonymous)"
+ " bind as \"%s\" failed"
+ " with error \"%s\"\n",
+ lsc[ 0 ]->bound_dn,
+ ldap_err2string( rc ) ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ANY,
"==>meta_back_dobind: (anonymous) bind as \"%s\" failed"
" with error \"%s\"\n%s",
lsc[ 0 ]->bound_dn,
ldap_err2string( rc ), "" );
+#endif /* !NEW_LOGGING */
/*
* null cred bind should always succeed
send_ldap_result( lc->conn, op, err, match, msg,
NULL, NULL );
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_DEBUG_NOTICE,
+ "meta_back_op_result: target"
+ " <%d> sending msg \"%s\""
+ " (matched \"%s\")\n",
+ i, ( msg ? msg : "" ),
+ ( match ? match : "" ) ));
+#else /* !NEW_LOGGING */
Debug(LDAP_DEBUG_ANY,
"==> meta_back_op_result: target <%d> sending msg \"%s\" (matched \"%s\")\n",
i,
( msg ? msg : "" ),
( match ? match : "" ) );
+#endif /* !NEW_LOGGING */
/* better test the pointers before freeing? */
if ( match ) {
if ( mdn == NULL ) {
mdn = ( char * )dn;
}
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] compareDn: \"%s\" -> \"%s\"\n",
+ dn, mdn ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> compareDn: \"%s\" -> \"%s\"\n%s",
dn, 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 ( mmatch == NULL ) {
mmatch = ( char * )match;
}
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] matchedDn: \"%s\" -> \"%s\"\n",
+ match, mmatch ));
+#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 );
ldap_free_urldesc( ludp );
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "config", LDAP_LEVEL_INFO,
+ "meta_back_db_config:"
+ " URI \"%s\", suffix \"%s\"\n",
+ li->targets[ i ]->uri,
+ li->targets[ i ]->suffix ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_CONFIG,
- "==>meta_back_db_config: URI \"%s\", suffix \"%s\"%s\n",
+ "==>meta_back_db_config: URI \"%s\", suffix \"%s\"\n%s",
li->targets[ i ]->uri, li->targets[ i ]->suffix, "" );
-
+#endif /* !NEW_LOGGING */
+
/* default target directive */
} else if ( strcasecmp( argv[ 0 ], "default-target" ) == 0 ) {
int i = li->ntargets-1;
if ( lsc->bound_dn == NULL ) {
lsc->bound_dn = ch_strdup( conn->c_cdn );
}
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] bindDn: \"%s\" -> \"%s\"\n",
+ conn->c_cdn, lsc->bound_dn ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> bindDn: \"%s\" -> \"%s\"\n%s",
conn->c_cdn, lsc->bound_dn, "" );
+#endif /* !NEW_LOGGING */
break;
case REWRITE_REGEXEC_UNWILLING:
return NULL;
}
-
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
+ "meta_back_getconn: got target %d"
+ " for ndn=\"%s\" from cache\n", i, ndn ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_CACHE,
"==>meta_back_getconn: got target %d for ndn=\"%s\" from cache\n%s",
i, ndn, "" );
-
+#endif /* !NEW_LOGGING */
+
/*
* Clear all other candidates
*/
ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
+ "meta_back_getconn: conn %ld inserted\n",
+ lc->conn->c_connid ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_TRACE,
"=>meta_back_getconn: conn %ld inserted\n%s%s",
lc->conn->c_connid, "", "" );
+#endif /* !NEW_LOGGING */
/*
* Err could be -1 in case a duplicate metaconn is inserted
return NULL;
}
} else {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
+ "meta_back_getconn: conn %ld fetched\n",
+ lc->conn->c_connid ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_TRACE,
"=>meta_back_getconn: conn %ld fetched\n%s%s",
lc->conn->c_connid, "", "" );
+#endif /* !NEW_LOGGING */
}
return lc;
if ( mdn == NULL ) {
mdn = ( char * )dn;
}
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] deleteDn: \"%s\" -> \"%s\"\n",
+ dn, mdn ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS, "rw> deleteDn: \"%s\" -> \"%s\"\n%s",
dn, 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:
- return( -1 );
+ send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ NULL, "Operations error", NULL, NULL );
+ return -1;
}
ldap_delete_s( lc->conns[ candidate ]->ld, mdn );
if ( mop_ndn == NULL ) {
mop_ndn = ( char * )op_ndn;
}
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] bindDn (op ndn in group):"
+ \"%s\" -> \"%s\"\n",
+ op_ndn, mop_ndn ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> bindDn (op ndn in group):"
" \"%s\" -> \"%s\"\n%s",
op_ndn, mop_ndn, "" );
+#endif /* !NEW_LOGGING */
break;
case REWRITE_REGEXEC_UNWILLING:
if ( mgr_ndn == NULL ) {
mgr_ndn = ( char * )gr_ndn;
}
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] searchBase (gr ndn in group):"
+ " \"%s\" -> \"%s\"\n",
+ gr_ndn, mgr_ndn ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> searchBase (gr ndn in group):"
" \"%s\" -> \"%s\"\n%s",
gr_ndn, mgr_ndn, "" );
+#endif /* !NEW_LOGGING */
break;
case REWRITE_REGEXEC_UNWILLING:
if ( mdn == NULL ) {
mdn = ( char * )dn;
}
- Debug( LDAP_DEBUG_ARGS, "rw> modifyDN: \"%s\" -> \"%s\"\n%s",
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] modifyDn: \"%s\" -> \"%s\"\n",
+ dn, mdn ));
+#else /* !NEW_LOGGING */
+ Debug( LDAP_DEBUG_ARGS, "rw> modifyDn: \"%s\" -> \"%s\"\n%s",
dn, 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:
- return( -1 );
+ send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ NULL, "Operations error", NULL, NULL );
+ return -1;
}
for ( i = 0, ml = modlist; ml; i++ ,ml = ml->sml_next )
if ( mnewSuperior == NULL ) {
mnewSuperior = ( char * )newSuperior;
}
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] newSuperiorDn:"
+ " \"%s\" -> \"%s\"\n",
+ newSuperior, mnewSuperior ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS, "rw> newSuperiorDn:"
" \"%s\" -> \"%s\"\n%s",
newSuperior, mnewSuperior, "" );
+#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:
- return( -1 );
+ send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ NULL, "Operations error",
+ NULL, NULL );
+ return -1;
}
}
if ( mdn == NULL ) {
mdn = ( char * )dn;
}
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] modrDn: \"%s\" -> \"%s\"\n",
+ dn, mdn ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS, "rw> modrDn: \"%s\" -> \"%s\"\n%s",
dn, 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:
- return( -1 );
+ send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ NULL, "Operations error", NULL, NULL );
+ return -1;
}
ldap_rename2_s( lc->conns[ candidate ]->ld, mdn, newrdn,
return meta_back_op_result( lc, op );
}
+
if ( mbase == NULL ) {
mbase = realbase;
}
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] searchBase: \"%s\" -> \"%s\"\n",
+ base, mbase ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS, "rw> searchBase: \"%s\" -> \"%s\"\n%s",
base, mbase, "" );
+#endif /* !NEW_LOGGING */
break;
case REWRITE_REGEXEC_UNWILLING:
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
NULL, "Unwilling to perform",
NULL, NULL );
- /* continue to the next case */
+ rc = -1;
+ goto finish;
case REWRITE_REGEXEC_ERR:
+ send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+ NULL, "Operations error",
+ NULL, NULL );
rc = -1;
goto finish;
}
}
mfilter = ( char * )filterstr;
}
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] searchFilter: \"%s\" -> \"%s\"\n",
+ filterstr, mfilter ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> searchFilter: \"%s\" -> \"%s\"\n%s",
filterstr, mfilter, "" );
+#endif /* !NEW_LOGGING */
break;
case REWRITE_REGEXEC_UNWILLING:
ldap_get_option( lsc[ 0 ]->ld,
LDAP_OPT_MATCHED_DN, &match );
- Debug( LDAP_DEBUG_ARGS,
- "meta_back_search=> [%d] match=\"%s\" err=\"%s\"\n",
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
+ "meta_back_search [%d]"
+ " match=\"%s\" err=\"%s\"\n",
+ i, match, err ));
+#else /* !NEW_LOGGING */
+ Debug( LDAP_DEBUG_ANY,
+ "=>meta_back_search [%d] match=\"%s\" err=\"%s\"\n",
i, match, err );
+#endif /* !NEW_LOGGING */
last = i;
rc = 0;
if ( mmatch == NULL ) {
mmatch = ( char * )match;
}
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] matchedDn: \"%s\" -> \"%s\"\n",
+ match, mmatch ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS, "rw> matchedDn:"
" \"%s\" -> \"%s\"\n%s",
match, mmatch, "" );
+#endif /* !NEW_LOGGING */
break;
case REWRITE_REGEXEC_UNWILLING:
if ( ent.e_dn == NULL ) {
ent.e_dn = dn;
} else {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+ "[rw] searchResult[%d]:"
+ " \"%s\" -> \"%s\"\n",
+ target, dn, ent.e_dn ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS, "rw> searchResult[%d]: \"%s\""
" -> \"%s\"\n", target, dn, ent.e_dn );
+#endif /* !NEW_LOGGING */
free( dn );
dn = NULL;
}
char *newval;
switch ( rewrite_session( li->targets[ target ]->rwinfo,
- "searchResult", bv->bv_val,
+ "searchResult",
+ bv->bv_val,
lc->conn, &newval )) {
case REWRITE_REGEXEC_OK:
/* left as is */
if ( newval == NULL ) {
break;
}
- Debug( LDAP_DEBUG_ARGS,
- "rw> searchResult on attr=%s: \"%s\" -> \"%s\"\n",
- attr->a_desc->ad_type->sat_cname,
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend",
+ LDAP_LEVEL_DETAIL1,
+ "[rw] searchResult on"
+ " attr=%s:"
+ " \"%s\" -> \"%s\"\n",
+ attr->a_desc->ad_type->sat_cname,
+ bv->bv_val, newval ));
+#else /* !NEW_LOGGING */
+ Debug( LDAP_DEBUG_ARGS,
+ "rw> searchResult on attr=%s:"
+ " \"%s\" -> \"%s\"\n",
+ attr->a_desc->ad_type->sat_cname,
bv->bv_val, newval );
-
+#endif /* !NEW_LOGGING */
+
free( bv->bv_val );
bv->bv_val = newval;
bv->bv_len = strlen( newval );
struct metainfo *li = ( struct metainfo * )be->be_private;
struct metaconn *lc, lc_curr;
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
+ "meta_back_conn_destroy: fetching conn %ld\n",
+ conn->c_connid ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_TRACE,
"=>meta_back_conn_destroy: fetching conn %ld\n%s%s",
conn->c_connid, "", "" );
+#endif /* !NEW_LOGGING */
lc_curr.conn = conn;
if ( lc ) {
int i;
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
+ "meta_back_conn_destroy: destroying conn %ld\n",
+ lc->conn->c_connid ));
+#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_TRACE,
"=>meta_back_conn_destroy: destroying conn %ld\n%s%s",
lc->conn->c_connid, "", "" );
+#endif /* !NEW_LOGGING */
/*
* Cleanup rewrite session