mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
add "searchFilterAttrDN" rewrite context, and allow filterstring rewrite
This commit is contained in:
parent
6a75d14930
commit
c507808524
@ -376,7 +376,7 @@ rwm_matched( Operation *op, SlapReply *rs )
|
|||||||
#ifdef ENABLE_REWRITE
|
#ifdef ENABLE_REWRITE
|
||||||
dc.conn = op->o_conn;
|
dc.conn = op->o_conn;
|
||||||
dc.rs = rs;
|
dc.rs = rs;
|
||||||
dc.ctx = "matchedDn";
|
dc.ctx = "matchedDN";
|
||||||
#else
|
#else
|
||||||
dc.tofrom = 0;
|
dc.tofrom = 0;
|
||||||
dc.normalized = 0;
|
dc.normalized = 0;
|
||||||
@ -419,7 +419,7 @@ rwm_send_entry( Operation *op, SlapReply *rs )
|
|||||||
#ifdef ENABLE_REWRITE
|
#ifdef ENABLE_REWRITE
|
||||||
dc.conn = op->o_conn;
|
dc.conn = op->o_conn;
|
||||||
dc.rs = NULL;
|
dc.rs = NULL;
|
||||||
dc.ctx = "searchResultDN";
|
dc.ctx = "searchResult";
|
||||||
#else
|
#else
|
||||||
dc.tofrom = 0;
|
dc.tofrom = 0;
|
||||||
dc.normalized = 0;
|
dc.normalized = 0;
|
||||||
|
@ -304,7 +304,7 @@ rwm_suffix_massage_config(
|
|||||||
ch_free( rargv[ 2 ] );
|
ch_free( rargv[ 2 ] );
|
||||||
|
|
||||||
rargv[ 0 ] = "rewriteContext";
|
rargv[ 0 ] = "rewriteContext";
|
||||||
rargv[ 1 ] = "searchResultDN";
|
rargv[ 1 ] = "searchResult";
|
||||||
rargv[ 2 ] = NULL;
|
rargv[ 2 ] = NULL;
|
||||||
rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
|
rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
|
||||||
|
|
||||||
@ -320,14 +320,14 @@ rwm_suffix_massage_config(
|
|||||||
rargv[ 0 ] = "rewriteContext";
|
rargv[ 0 ] = "rewriteContext";
|
||||||
rargv[ 1 ] = "matchedDN";
|
rargv[ 1 ] = "matchedDN";
|
||||||
rargv[ 2 ] = "alias";
|
rargv[ 2 ] = "alias";
|
||||||
rargv[ 3 ] = "searchResultDN";
|
rargv[ 3 ] = "searchResult";
|
||||||
rargv[ 4 ] = NULL;
|
rargv[ 4 ] = NULL;
|
||||||
rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
|
rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
|
||||||
|
|
||||||
rargv[ 0 ] = "rewriteContext";
|
rargv[ 0 ] = "rewriteContext";
|
||||||
rargv[ 1 ] = "searchAttrDN";
|
rargv[ 1 ] = "searchAttrDN";
|
||||||
rargv[ 2 ] = "alias";
|
rargv[ 2 ] = "alias";
|
||||||
rargv[ 3 ] = "searchResultDN";
|
rargv[ 3 ] = "searchResult";
|
||||||
rargv[ 4 ] = NULL;
|
rargv[ 4 ] = NULL;
|
||||||
rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
|
rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
|
||||||
|
|
||||||
|
@ -46,10 +46,10 @@ rwm_dn_massage(
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
switch ( rewrite_session( dc->rwmap->rwm_rw, dc->ctx,
|
rc = rewrite_session( dc->rwmap->rwm_rw, dc->ctx,
|
||||||
(dn->bv_len ? dn->bv_val : ""),
|
( dn->bv_len ? dn->bv_val : "" ),
|
||||||
dc->conn, &res->bv_val ) )
|
dc->conn, &res->bv_val );
|
||||||
{
|
switch ( rc ) {
|
||||||
case REWRITE_REGEXEC_OK:
|
case REWRITE_REGEXEC_OK:
|
||||||
if ( res->bv_val != NULL ) {
|
if ( res->bv_val != NULL ) {
|
||||||
res->bv_len = strlen( res->bv_val );
|
res->bv_len = strlen( res->bv_val );
|
||||||
@ -58,10 +58,12 @@ rwm_dn_massage(
|
|||||||
}
|
}
|
||||||
#ifdef NEW_LOGGING
|
#ifdef NEW_LOGGING
|
||||||
LDAP_LOG( BACK_LDAP, DETAIL1,
|
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 */
|
#else /* !NEW_LOGGING */
|
||||||
Debug( LDAP_DEBUG_ARGS,
|
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 */
|
#endif /* !NEW_LOGGING */
|
||||||
rc = LDAP_SUCCESS;
|
rc = LDAP_SUCCESS;
|
||||||
break;
|
break;
|
||||||
@ -82,6 +84,7 @@ rwm_dn_massage(
|
|||||||
rc = LDAP_OTHER;
|
rc = LDAP_OTHER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ map_attr_value(
|
|||||||
dncookie fdc = *dc;
|
dncookie fdc = *dc;
|
||||||
|
|
||||||
#ifdef ENABLE_REWRITE
|
#ifdef ENABLE_REWRITE
|
||||||
fdc.ctx = "searchFilter";
|
fdc.ctx = "searchFilterAttrDN";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch ( rwm_dn_massage( &fdc, value, &vtmp ) ) {
|
switch ( rwm_dn_massage( &fdc, value, &vtmp ) ) {
|
||||||
@ -236,8 +236,8 @@ map_attr_value(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
rwm_filter_map_rewrite(
|
rwm_int_filter_map_rewrite(
|
||||||
dncookie *dc,
|
dncookie *dc,
|
||||||
Filter *f,
|
Filter *f,
|
||||||
struct berval *fstr,
|
struct berval *fstr,
|
||||||
@ -420,7 +420,7 @@ rwm_filter_map_rewrite(
|
|||||||
for ( p = f->f_list; p != NULL; p = p->f_next ) {
|
for ( p = f->f_list; p != NULL; p = p->f_next ) {
|
||||||
len = fstr->bv_len;
|
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 -1;
|
||||||
}
|
}
|
||||||
@ -497,6 +497,73 @@ rwm_filter_map_rewrite(
|
|||||||
return 0;
|
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
|
* I don't like this much, but we need two different
|
||||||
* functions because different heap managers may be
|
* functions because different heap managers may be
|
||||||
|
Loading…
Reference in New Issue
Block a user