ch_free( rargv[ 2 ] );
rargv[ 0 ] = "rewriteContext";
- rargv[ 1 ] = "searchResultDN";
+ rargv[ 1 ] = "searchResult";
rargv[ 2 ] = NULL;
rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
rargv[ 0 ] = "rewriteContext";
rargv[ 1 ] = "matchedDN";
rargv[ 2 ] = "alias";
- rargv[ 3 ] = "searchResultDN";
+ rargv[ 3 ] = "searchResult";
rargv[ 4 ] = NULL;
rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
rargv[ 0 ] = "rewriteContext";
rargv[ 1 ] = "searchAttrDN";
rargv[ 2 ] = "alias";
- rargv[ 3 ] = "searchResultDN";
+ rargv[ 3 ] = "searchResult";
rargv[ 4 ] = NULL;
rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
{
int rc = 0;
- switch ( rewrite_session( dc->rwmap->rwm_rw, dc->ctx,
- (dn->bv_len ? dn->bv_val : ""),
- dc->conn, &res->bv_val ) )
- {
+ rc = rewrite_session( dc->rwmap->rwm_rw, dc->ctx,
+ ( dn->bv_len ? dn->bv_val : "" ),
+ dc->conn, &res->bv_val );
+ switch ( rc ) {
case REWRITE_REGEXEC_OK:
if ( res->bv_val != NULL ) {
res->bv_len = strlen( res->bv_val );
}
#ifdef NEW_LOGGING
LDAP_LOG( BACK_LDAP, DETAIL1,
- "[rw] %s: \"%s\" -> \"%s\"\n", dc->ctx, dn->bv_val, res->bv_val );
+ "[rw] %s: \"%s\" -> \"%s\"\n",
+ dc->ctx, dn->bv_val, res->bv_val );
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
- "[rw] %s: \"%s\" -> \"%s\"\n", dc->ctx, dn->bv_val, res->bv_val );
+ "[rw] %s: \"%s\" -> \"%s\"\n",
+ dc->ctx, dn->bv_val, res->bv_val );
#endif /* !NEW_LOGGING */
rc = LDAP_SUCCESS;
break;
rc = LDAP_OTHER;
break;
}
+
return rc;
}
dncookie fdc = *dc;
#ifdef ENABLE_REWRITE
- fdc.ctx = "searchFilter";
+ fdc.ctx = "searchFilterAttrDN";
#endif
switch ( rwm_dn_massage( &fdc, value, &vtmp ) ) {
return 0;
}
-int
-rwm_filter_map_rewrite(
+static int
+rwm_int_filter_map_rewrite(
dncookie *dc,
Filter *f,
struct berval *fstr,
for ( p = f->f_list; p != NULL; p = p->f_next ) {
len = fstr->bv_len;
- if ( rwm_filter_map_rewrite( dc, p, &vtmp, remap ) )
+ if ( rwm_int_filter_map_rewrite( dc, p, &vtmp, remap ) )
{
return -1;
}
return 0;
}
+int
+rwm_filter_map_rewrite(
+ dncookie *dc,
+ Filter *f,
+ struct berval *fstr,
+ int remap )
+{
+ int rc;
+ dncookie fdc;
+ struct berval ftmp;
+
+ rc = rwm_int_filter_map_rewrite( dc, f, fstr, remap );
+
+#ifdef ENABLE_REWRITE
+ if ( rc != LDAP_SUCCESS ) {
+ return rc;
+ }
+
+ fdc = *dc;
+ ftmp = *fstr;
+
+ fdc.ctx = "searchFilter";
+
+ switch ( rewrite_session( fdc.rwmap->rwm_rw, fdc.ctx,
+ ( ftmp.bv_len ? ftmp.bv_val : "" ),
+ fdc.conn, &fstr->bv_val )) {
+ case REWRITE_REGEXEC_OK:
+ if ( fstr->bv_val != NULL ) {
+ fstr->bv_len = strlen( fstr->bv_val );
+ free( ftmp.bv_val );
+ } else {
+ *fstr = ftmp;
+ }
+
+#ifdef NEW_LOGGING
+ LDAP_LOG( BACK_LDAP, DETAIL1,
+ "[rw] %s: \"%s\" -> \"%s\"\n",
+ dc->ctx, ftmp.bv_val, fstr->bv_val );
+#else /* !NEW_LOGGING */
+ Debug( LDAP_DEBUG_ARGS,
+ "[rw] %s: \"%s\" -> \"%s\"\n",
+ dc->ctx, ftmp.bv_val, fstr->bv_val );
+#endif /* !NEW_LOGGING */
+ rc = LDAP_SUCCESS;
+ break;
+
+ case REWRITE_REGEXEC_UNWILLING:
+ if ( fdc.rs ) {
+ fdc.rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+ fdc.rs->sr_text = "Operation not allowed";
+ }
+ rc = LDAP_UNWILLING_TO_PERFORM;
+ break;
+
+ case REWRITE_REGEXEC_ERR:
+ if ( fdc.rs ) {
+ fdc.rs->sr_err = LDAP_OTHER;
+ fdc.rs->sr_text = "Rewrite error";
+ }
+ rc = LDAP_OTHER;
+ break;
+ }
+
+#endif /* ENABLE_REWRITE */
+ return rc;
+}
+
/*
* I don't like this much, but we need two different
* functions because different heap managers may be