/*
* Rewrite the add dn, if needed
*/
+ dc.rwmap = &li->rwmap;
#ifdef ENABLE_REWRITE
- dc.rw = li->rwinfo;
dc.conn = op->o_conn;
dc.rs = rs;
dc.ctx = "addDn";
#else
- dc.li = li;
dc.tofrom = 1;
dc.normalized = 0;
#endif
continue;
}
- ldap_back_map(&li->at_map, &a->a_desc->ad_cname, &mapped,
+ ldap_back_map(&li->rwmap.rwm_at, &a->a_desc->ad_cname, &mapped,
BACKLDAP_MAP);
if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0') {
continue;
struct berval dst;
};
+struct ldaprwmap {
+ /*
+ * DN rewriting
+ */
+#ifdef ENABLE_REWRITE
+ struct rewrite_info *rwm_rw;
+#else /* !ENABLE_REWRITE */
+ /* some time the suffix massaging without librewrite
+ * will be disabled */
+ BerVarray rwm_suffix_massage;
+#endif /* !ENABLE_REWRITE */
+
+ /*
+ * Attribute/objectClass mapping
+ */
+ struct ldapmap rwm_oc;
+ struct ldapmap rwm_at;
+};
+
struct ldapinfo {
struct slap_backend_db *be;
char *url;
ldap_pvt_thread_mutex_t conn_mutex;
int savecred;
Avlnode *conntree;
+
+#if 0
#ifdef ENABLE_REWRITE
struct rewrite_info *rwinfo;
#else /* !ENABLE_REWRITE */
struct ldapmap oc_map;
struct ldapmap at_map;
-};
+#endif
-struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs);
-int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs);
-int ldap_back_map_result(SlapReply *rs);
-int ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs,
- ber_int_t msgid, int sendok);
-int back_ldap_LTX_init_module(int argc, char *argv[]);
+ struct ldaprwmap rwmap;
+};
/* Whatever context ldap_back_dn_massage needs... */
typedef struct dncookie {
+ struct ldaprwmap *rwmap;
+
#ifdef ENABLE_REWRITE
- struct rewrite_info *rw;
Connection *conn;
char *ctx;
SlapReply *rs;
#else
- struct ldapinfo *li;
int normalized;
int tofrom;
#endif
} dncookie;
+struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs);
+int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs);
+int ldap_back_map_result(SlapReply *rs);
+int ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs,
+ ber_int_t msgid, int sendok);
+int back_ldap_LTX_init_module(int argc, char *argv[]);
+
int ldap_back_dn_massage(dncookie *dc, struct berval *dn,
struct berval *res);
char **argv );
extern int
-ldap_back_filter_map_rewrite_(
-#ifdef ENABLE_REWRITE
- struct rewrite_info *info,
- void *cookie,
-#endif /* ENABLE_REWRITE */
- struct ldapmap *at_map,
- struct ldapmap *oc_map,
+ldap_back_filter_map_rewrite(
+ dncookie *dc,
Filter *f,
struct berval *fstr,
int remap );
/*
* Rewrite the bind dn if needed
*/
+ dc.rwmap = &li->rwmap;
#ifdef ENABLE_REWRITE
- dc.rw = li->rwinfo;
dc.conn = op->o_conn;
dc.rs = rs;
dc.ctx = "bindDn";
#else
- dc.li = li;
dc.tofrom = 1;
dc.normalized = 0;
#endif
* since we may have different entries
* for the same connection
*/
- ( void )rewrite_session_init( li->rwinfo, op->o_conn );
+ ( void )rewrite_session_init( li->rwmap.rwm_rw, op->o_conn );
#endif /* ENABLE_REWRITE */
ldap_pvt_thread_mutex_init( &lc->lc_mutex );
/*
* Rewrite the bind dn if needed
*/
+ dc.rwmap = &li->rwmap;
#ifdef ENABLE_REWRITE
- dc.rw = li->rwinfo;
dc.conn = op->o_conn;
dc.rs = rs;
dc.ctx = "bindDn";
struct berval dn, mdn;
dncookie dc;
+ dc.rwmap = &li->rwmap;
#ifdef ENABLE_REWRITE
- dc.rw = li->rwinfo;
dc.conn = op->o_conn;
dc.rs = rs;
dc.ctx = "matchedDn";
#else
- dc.li = li;
dc.tofrom = 0;
dc.normalized = 0;
#endif
/*
* Rewrite the compare dn, if needed
*/
+ dc.rwmap = &li->rwmap;
#ifdef ENABLE_REWRITE
- dc.rw = li->rwinfo;
dc.conn = op->o_conn;
dc.rs = rs;
dc.ctx = "compareDn";
#else
- dc.li = li;
dc.tofrom = 1;
dc.normalized = 0;
#endif
}
if ( op->oq_compare.rs_ava->aa_desc == slap_schema.si_ad_objectClass ) {
- ldap_back_map(&li->oc_map, &op->orc_ava->aa_value, &mapped_val,
- BACKLDAP_MAP);
+ ldap_back_map(&li->rwmap.rwm_oc, &op->orc_ava->aa_value,
+ &mapped_val, BACKLDAP_MAP);
if (mapped_val.bv_val == NULL || mapped_val.bv_val[0] == '\0') {
return( -1 );
}
mapped_at = op->orc_ava->aa_desc->ad_cname;
} else {
- ldap_back_map(&li->at_map, &op->orc_ava->aa_desc->ad_cname, &mapped_at,
+ ldap_back_map(&li->rwmap.rwm_at,
+ &op->orc_ava->aa_desc->ad_cname, &mapped_at,
BACKLDAP_MAP);
if (mapped_at.bv_val == NULL || mapped_at.bv_val[0] == '\0') {
return( -1 );
* FIXME: no extra rewrite capabilities should be added
* to the database
*/
- rc = suffix_massage_config( li->rwinfo, &pvnc, &nvnc, &prnc, &nrnc );
+ rc = suffix_massage_config( li->rwmap.rwm_rw,
+ &pvnc, &nvnc, &prnc, &nrnc );
free( nvnc.bv_val );
free( pvnc.bv_val );
free( nrnc.bv_val );
/* rewrite stuff ... */
} else if ( strncasecmp( argv[0], "rewrite", 7 ) == 0 ) {
#ifdef ENABLE_REWRITE
- return rewrite_parse( li->rwinfo, fname, lineno, argc, argv );
+ return rewrite_parse( li->rwmap.rwm_rw,
+ fname, lineno, argc, argv );
#else /* !ENABLE_REWRITE */
fprintf( stderr, "%s: line %d: rewrite capabilities "
/* objectclass/attribute mapping */
} else if ( strcasecmp( argv[0], "map" ) == 0 ) {
- return ldap_back_map_config( &li->oc_map, &li->at_map,
+ return ldap_back_map_config( &li->rwmap.rwm_oc,
+ &li->rwmap.rwm_at,
fname, lineno, argc, argv );
/* anything else */
/*
* Rewrite the request dn, if needed
*/
+ dc.rwmap = &li->rwmap;
#ifdef ENABLE_REWRITE
- dc.rw = li->rwinfo;
dc.conn = op->o_conn;
dc.rs = rs;
dc.ctx = "deleteDn";
#else
- dc.li = li;
dc.tofrom = 1;
dc.normalized = 0;
#endif
return LDAP_UNWILLING_TO_PERFORM;
}
if (id.bv_len) {
+ dc.rwmap = &li->rwmap;
#ifdef ENABLE_REWRITE
- dc.rw = li->rwinfo;
dc.conn = op->o_conn;
dc.rs = rs;
dc.ctx = "modifyPwd";
#else
- dc.li = li;
dc.tofrom = 1;
dc.normalized = 0;
#endif
li->bindpw.bv_len = 0;
#ifdef ENABLE_REWRITE
- li->rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
- if ( li->rwinfo == NULL ) {
+ li->rwmap.rwm_rw = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
+ if ( li->rwmap.rwm_rw == NULL ) {
ch_free( li );
return -1;
}
ldap_pvt_thread_mutex_init( &li->conn_mutex );
- ldap_back_map_init( &li->at_map, &mapping );
+ ldap_back_map_init( &li->rwmap.rwm_oc, &mapping );
+ ldap_back_map_init( &li->rwmap.rwm_at, &mapping );
li->be = be;
be->be_private = li;
avl_free( li->conntree, ldap_back_conn_free );
}
#ifdef ENABLE_REWRITE
- if (li->rwinfo) {
- rewrite_info_delete( li->rwinfo );
+ if (li->rwmap.rwm_rw) {
+ rewrite_info_delete( li->rwmap.rwm_rw );
}
#else /* !ENABLE_REWRITE */
if (li->suffix_massage) {
}
#endif /* !ENABLE_REWRITE */
- avl_free( li->oc_map.remap, NULL );
- avl_free( li->oc_map.map, mapping_free );
- avl_free( li->at_map.remap, NULL );
- avl_free( li->at_map.map, mapping_free );
+ avl_free( li->rwmap.rwm_oc.remap, NULL );
+ avl_free( li->rwmap.rwm_oc.map, mapping_free );
+ avl_free( li->rwmap.rwm_at.remap, NULL );
+ avl_free( li->rwmap.rwm_at.map, mapping_free );
ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
ldap_pvt_thread_mutex_destroy( &li->conn_mutex );
return;
}
-char *
-ldap_back_map_filter(
- struct ldapmap *at_map,
- struct ldapmap *oc_map,
- struct berval *f,
- int remap
-)
-{
- char *nf, *p, *q, *s, c;
- int len, extra, plen, in_quote;
- struct berval m, tmp;
-
- if (f == NULL)
- return(NULL);
-
- len = f->bv_len;
- extra = len;
- len *= 2;
- nf = ch_malloc( len + 1 );
- if (nf == NULL)
- return(NULL);
-
- /* this loop assumes the filter ends with one
- * of the delimiter chars -- probably ')'.
- */
-
- s = nf;
- q = NULL;
- in_quote = 0;
- for (p = f->bv_val; (c = *p); p++) {
- if (c == '"') {
- in_quote = !in_quote;
- if (q != NULL) {
- plen = p - q;
- AC_MEMCPY(s, q, plen);
- s += plen;
- q = NULL;
- }
- *s++ = c;
- } else if (in_quote) {
- /* ignore everything in quotes --
- * what about attrs in DNs?
- */
- *s++ = c;
- } else if (c != '(' && c != ')'
- && c != '=' && c != '>' && c != '<'
- && c != '|' && c != '&')
- {
- if (q == NULL)
- q = p;
- } else {
- if (q != NULL) {
- *p = 0;
- tmp.bv_len = p - q;
- tmp.bv_val = q;
- ldap_back_map(at_map, &tmp, &m, remap);
- if (m.bv_val == NULL || m.bv_val[0] == '\0') {
- /*
- * FIXME: are we sure we need to search
- * oc_map if at_map fails?
- */
- ldap_back_map(oc_map, &tmp, &m, remap);
- if (m.bv_val == NULL || m.bv_val[0] == '\0') {
- m = tmp;
- }
- }
- extra += p - q;
- plen = m.bv_len;
- extra -= plen;
- if (extra < 0) {
- char *tmpnf;
- while (extra < 0) {
- extra += len;
- len *= 2;
- }
- s -= (long)nf;
- tmpnf = ch_realloc(nf, len + 1);
- if (tmpnf == NULL) {
- ch_free(nf);
- return(NULL);
- }
- nf = tmpnf;
- s += (long)nf;
- }
- AC_MEMCPY(s, m.bv_val, plen);
- s += plen;
- *p = c;
- q = NULL;
- }
- *s++ = c;
- }
- }
- *s = 0;
- return(nf);
-}
-
int
ldap_back_map_attrs(
struct ldapmap *at_map,
return LDAP_SUCCESS;
}
-#ifdef ENABLE_REWRITE
-
-static int
-map_attr_value_(
- struct rewrite_info *info,
- void *cookie,
- struct ldapmap *at_map,
- struct ldapmap *oc_map,
+int
+map_attr_value(
+ dncookie *dc,
AttributeDescription *ad,
struct berval *mapped_attr,
struct berval *value,
struct berval vtmp;
int freeval = 0;
- ldap_back_map( at_map, &ad->ad_cname, mapped_attr, remap );
+ ldap_back_map( &dc->rwmap->rwm_at, &ad->ad_cname, mapped_attr, remap );
if ( mapped_attr->bv_val == NULL || mapped_attr->bv_val[0] == '\0') {
/*
* FIXME: are we sure we need to search oc_map if at_map fails?
*/
- ldap_back_map( oc_map, &ad->ad_cname, mapped_attr, remap );
+ ldap_back_map( &dc->rwmap->rwm_oc, &ad->ad_cname, mapped_attr, remap );
if ( mapped_attr->bv_val == NULL || mapped_attr->bv_val[0] == '\0' ) {
*mapped_attr = ad->ad_cname;
}
if ( strcmp( ad->ad_type->sat_syntax->ssyn_oid, SLAPD_DN_SYNTAX ) == 0 )
{
- switch ( rewrite_session( info, "searchFilter",
- value->bv_val, cookie, &vtmp.bv_val ) ) {
+ dncookie fdc = *dc;
+
+ fdc.ctx = "searchFilter";
+
+ switch ( ldap_back_dn_massage( &fdc, value, &vtmp ) ) {
case REWRITE_REGEXEC_OK:
- if ( vtmp.bv_val == NULL ) {
- vtmp = *value;
- } else {
- vtmp.bv_len = strlen( vtmp.bv_val );
+ if ( vtmp.bv_val != value->bv_val ) {
freeval = 1;
}
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_LDAP, DETAIL1,
- "[rw] searchFilter: \"%s\" -> \"%s\"\n",
- value->bv_val, vtmp.bv_val, 0 );
-#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS, "rw> searchFilter: \"%s\" -> \"%s\"\n%s",
- value->bv_val, vtmp.bv_val, "" );
-#endif /* !NEW_LOGGING */
break;
-
case REWRITE_REGEXEC_UNWILLING:
return -1;
}
} else if ( ad == slap_schema.si_ad_objectClass || ad == slap_schema.si_ad_structuralObjectClass ) {
- ldap_back_map( oc_map, value, &vtmp, remap );
+ ldap_back_map( &dc->rwmap->rwm_oc, value, &vtmp, remap );
if ( vtmp.bv_val == NULL || vtmp.bv_val[0] == '\0' ) {
vtmp = *value;
}
return 0;
}
-#define map_attr_value(at_map, oc_map, ad, mapped_attr, value, mapped_value, remap) \
- map_attr_value_(info, cookie, (at_map), (oc_map), (ad), (mapped_attr), (value), (mapped_value), (remap))
-#define ldap_back_filter_map_rewrite(at_map, oc_map, f, fstr, remap) \
- ldap_back_filter_map_rewrite_(info, cookie, (at_map), (oc_map), (f), (fstr), (remap))
-
-#else /* ! ENABLE_REWRITE */
-
-static int
-map_attr_value_(
- struct ldapmap *at_map,
- struct ldapmap *oc_map,
- AttributeDescription *ad,
- struct berval *mapped_attr,
- struct berval *value,
- struct berval *mapped_value,
- int remap )
-{
- struct berval vtmp;
-
- ldap_back_map( at_map, &ad->ad_cname, mapped_attr, remap );
- if ( mapped_attr->bv_val == NULL || mapped_attr->bv_val[0] == '\0') {
- /*
- * FIXME: are we sure we need to search oc_map if at_map fails?
- */
- ldap_back_map( oc_map, &ad->ad_cname, mapped_attr, remap );
- if ( mapped_attr->bv_val == NULL || mapped_attr->bv_val[0] == '\0' ) {
- *mapped_attr = ad->ad_cname;
- }
- }
-
- if ( value == NULL ) {
- return 0;
- }
-
- if ( strcmp( ad->ad_type->sat_syntax->ssyn_oid, SLAPD_DN_SYNTAX ) == 0 )
- {
- /* FIXME: use suffix massage capabilities */
- vtmp = *value;
-
- } else if ( ad == slap_schema.si_ad_objectClass || ad == slap_schema.si_ad_structuralObjectClass ) {
- ldap_back_map( oc_map, value, &vtmp, remap );
- if ( vtmp.bv_val == NULL || vtmp.bv_val[0] == '\0' ) {
- vtmp = *value;
- }
-
- } else {
- vtmp = *value;
- }
-
- filter_escape_value( &vtmp, mapped_value );
-
- return 0;
-}
-
-#define map_attr_value(at_map, oc_map, ad, mapped_attr, value, mapped_value, remap) \
- map_attr_value_((at_map), (oc_map), (ad), (mapped_attr), (value), (mapped_value), (remap))
-#define ldap_back_filter_map_rewrite(at_map, oc_map, f, fstr, remap) \
- ldap_back_filter_map_rewrite_((at_map), (oc_map), (f), (fstr), (remap))
-
-#endif /* ! ENABLE_REWRITE */
-
int
-ldap_back_filter_map_rewrite_(
-#ifdef ENABLE_REWRITE
- struct rewrite_info *info,
- void *cookie,
-#endif /* ENABLE_REWRITE */
- struct ldapmap *at_map,
- struct ldapmap *oc_map,
+ldap_back_filter_map_rewrite(
+ dncookie *dc,
Filter *f,
struct berval *fstr,
int remap )
switch ( f->f_choice ) {
case LDAP_FILTER_EQUALITY:
- if ( map_attr_value( at_map, oc_map, f->f_av_desc, &atmp,
+ if ( map_attr_value( dc, f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, remap ) )
{
return -1;
break;
case LDAP_FILTER_GE:
- if ( map_attr_value( at_map, oc_map, f->f_av_desc, &atmp,
- &f->f_av_value, &vtmp, remap ) )
+ if ( map_attr_value( dc, f->f_av_desc, &atmp,
+ &f->f_av_value, &vtmp, remap ) )
{
return -1;
}
break;
case LDAP_FILTER_LE:
- if ( map_attr_value( at_map, oc_map, f->f_av_desc, &atmp,
+ if ( map_attr_value( dc, f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, remap ) )
{
return -1;
break;
case LDAP_FILTER_APPROX:
- if ( map_attr_value( at_map, oc_map, f->f_av_desc, &atmp,
+ if ( map_attr_value( dc, f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, remap ) )
{
return -1;
break;
case LDAP_FILTER_SUBSTRINGS:
- if ( map_attr_value( at_map, oc_map, f->f_sub_desc, &atmp,
+ if ( map_attr_value( dc, f->f_sub_desc, &atmp,
NULL, NULL, remap ) )
{
return -1;
break;
case LDAP_FILTER_PRESENT:
- if ( map_attr_value( at_map, oc_map, f->f_desc, &atmp,
+ if ( map_attr_value( dc, f->f_desc, &atmp,
NULL, NULL, remap ) )
{
return -1;
for ( p = f->f_list; p != NULL; p = p->f_next ) {
len = fstr->bv_len;
- if ( ldap_back_filter_map_rewrite( at_map, oc_map, p, &vtmp, remap ) )
+ if ( ldap_back_filter_map_rewrite( dc, p, &vtmp, remap ) )
{
return -1;
}
case LDAP_FILTER_EXT: {
if ( f->f_mr_desc ) {
- if ( map_attr_value( at_map, oc_map, f->f_mr_desc, &atmp,
+ if ( map_attr_value( dc, f->f_mr_desc, &atmp,
&f->f_mr_value, &vtmp, remap ) )
{
return -1;
return 0;
}
+
/*
* Rewrite the modify dn, if needed
*/
+ dc.rwmap = &li->rwmap;
#ifdef ENABLE_REWRITE
- dc.rw = li->rwinfo;
dc.conn = op->o_conn;
dc.rs = rs;
dc.ctx = "modifyDn";
#else
- dc.li = li;
dc.tofrom = 1;
dc.normalized = 0;
#endif
dc.ctx = "modifyAttrDN";
#endif
for (i=0, ml=op->oq_modify.rs_modlist; ml; ml=ml->sml_next) {
+ int is_oc = 0;
+
if ( ml->sml_desc->ad_type->sat_no_user_mod ) {
continue;
}
- ldap_back_map(&li->at_map, &ml->sml_desc->ad_cname, &mapped,
- BACKLDAP_MAP);
- if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0') {
- continue;
+ if ( ml->sml_desc == slap_schema.si_ad_objectClass
+ || ml->sml_desc == slap_schema.si_ad_structuralObjectClass ) {
+ is_oc = 1;
+ mapped = ml->sml_desc->ad_cname;
+
+ } else {
+ ldap_back_map(&li->rwmap.rwm_at,
+ &ml->sml_desc->ad_cname,
+ &mapped, BACKLDAP_MAP);
+ if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0') {
+ continue;
+ }
}
modv[i] = &mods[i];
mods[i].mod_op = ml->sml_op | LDAP_MOD_BVALUES;
mods[i].mod_type = mapped.bv_val;
- if ( ml->sml_desc->ad_type->sat_syntax ==
- slap_schema.si_syn_distinguishedName ) {
- ldap_dnattr_rewrite( &dc, ml->sml_bvalues );
- }
+ if ( ml->sml_bvalues != NULL ) {
+ if ( is_oc ) {
+ for (j = 0; ml->sml_bvalues[j].bv_val; j++);
+ mods[i].mod_bvalues = (struct berval **)ch_malloc((j+1) *
+ sizeof(struct berval *));
+ for (j = 0; ml->sml_bvalues[j].bv_val; j++) {
+ ldap_back_map(&li->rwmap.rwm_oc,
+ &ml->sml_bvalues[j],
+ &mapped, BACKLDAP_MAP);
+ if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0') {
+ continue;
+ }
+ mods[i].mod_bvalues[j] = &mapped;
+ }
+ mods[i].mod_bvalues[j] = NULL;
+
+ } else {
+ if ( ml->sml_desc->ad_type->sat_syntax ==
+ slap_schema.si_syn_distinguishedName ) {
+ ldap_dnattr_rewrite( &dc, ml->sml_bvalues );
+ }
+
+ if ( ml->sml_bvalues == NULL ) {
+ continue;
+ }
+
+ for (j = 0; ml->sml_bvalues[j].bv_val; j++);
+ mods[i].mod_bvalues = (struct berval **)ch_malloc((j+1) *
+ sizeof(struct berval *));
+ for (j = 0; ml->sml_bvalues[j].bv_val; j++)
+ mods[i].mod_bvalues[j] = &ml->sml_bvalues[j];
+ mods[i].mod_bvalues[j] = NULL;
+ }
- if ( ml->sml_bvalues != NULL ) {
- for (j = 0; ml->sml_bvalues[j].bv_val; j++);
- mods[i].mod_bvalues = (struct berval **)ch_malloc((j+1) *
- sizeof(struct berval *));
- for (j = 0; ml->sml_bvalues[j].bv_val; j++)
- mods[i].mod_bvalues[j] = &ml->sml_bvalues[j];
- mods[i].mod_bvalues[j] = NULL;
} else {
mods[i].mod_bvalues = NULL;
}
return( -1 );
}
+ dc.rwmap = &li->rwmap;
#ifdef ENABLE_REWRITE
- dc.rw = li->rwinfo;
dc.conn = op->o_conn;
dc.rs = rs;
#else
- dc.li = li;
dc.tofrom = 1;
dc.normalized = 0;
#endif
/*
* Rewrite the search base, if required
*/
+ dc.rwmap = &li->rwmap;
#ifdef ENABLE_REWRITE
- dc.rw = li->rwinfo;
dc.conn = op->o_conn;
dc.rs = rs;
dc.ctx = "searchBase";
#else
- dc.li = li;
dc.tofrom = 1;
dc.normalized = 0;
#endif
return -1;
}
-#ifdef ENABLE_REWRITE
- rc = ldap_back_filter_map_rewrite_( li->rwinfo, op->o_conn,
- &li->at_map, &li->oc_map, op->oq_search.rs_filter, &mfilter,
- BACKLDAP_MAP );
-#else /* ! ENABLE_REWRITE */
- rc = ldap_back_filter_map_rewrite_( &li->at_map, &li->oc_map,
- op->oq_search.rs_filter, &mfilter, BACKLDAP_MAP );
-#endif /* ! ENABLE_REWRITE */
+ rc = ldap_back_filter_map_rewrite( &dc, op->oq_search.rs_filter,
+ &mfilter, BACKLDAP_MAP );
if ( rc ) {
rs->sr_err = LDAP_OTHER;
goto finish;
}
- rs->sr_err = ldap_back_map_attrs( &li->at_map, op->oq_search.rs_attrs,
+ rs->sr_err = ldap_back_map_attrs( &li->rwmap.rwm_at,
+ op->oq_search.rs_attrs,
BACKLDAP_MAP, &mapped_attrs );
if ( rs->sr_err ) {
rc = -1;
/*
* Rewrite the dn of the result, if needed
*/
+ dc.rwmap = &li->rwmap;
#ifdef ENABLE_REWRITE
- dc.rw = li->rwinfo;
dc.conn = op->o_conn;
dc.rs = NULL;
dc.ctx = "searchResult";
#else
- dc.li = li;
dc.tofrom = 0;
dc.normalized = 0;
#endif
dc.ctx = "searchAttrDN";
#endif
while ( ber_scanf( &ber, "{m", &a ) != LBER_ERROR ) {
- ldap_back_map(&li->at_map, &a, &mapped, BACKLDAP_REMAP);
+ ldap_back_map(&li->rwmap.rwm_at, &a, &mapped, BACKLDAP_REMAP);
if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0')
continue;
attr = (Attribute *)ch_malloc( sizeof(Attribute) );
} else if ( attr->a_desc == slap_schema.si_ad_objectClass
|| attr->a_desc == slap_schema.si_ad_structuralObjectClass ) {
for ( bv = attr->a_vals; bv->bv_val; bv++ ) {
- ldap_back_map(&li->oc_map, bv, &mapped,
+ ldap_back_map(&li->rwmap.rwm_oc, bv, &mapped,
BACKLDAP_REMAP);
if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0') {
LBER_FREE(bv->bv_val);
}
}
-next_attr:;
-
if ( normalize && last && attr->a_desc->ad_type->sat_equality &&
attr->a_desc->ad_type->sat_equality->smr_normalize ) {
int i;
/*
* Rewrite the search base, if required
*/
+ dc.rwmap = &li->rwmap;
#ifdef ENABLE_REWRITE
- dc.rw = li->rwinfo;
dc.conn = op->o_conn;
dc.rs = &rs;
dc.ctx = "searchBase";
#else
- dc.li = li;
dc.tofrom = 1;
dc.normalized = 1;
#endif
return 1;
}
- ldap_back_map(&li->at_map, &at->ad_cname, &mapped, BACKLDAP_MAP);
+ ldap_back_map(&li->rwmap.rwm_at, &at->ad_cname, &mapped, BACKLDAP_MAP);
if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0') {
rc = 1;
goto cleanup;
}
if (oc) {
char *ptr;
- ldap_back_map(&li->oc_map, &oc->soc_cname, &mapped,
+ ldap_back_map(&li->rwmap.rwm_oc, &oc->soc_cname, &mapped,
BACKLDAP_MAP);
filter = ch_malloc(sizeof("(objectclass=)") + mapped.bv_len);
ptr = lutil_strcopy(filter, "(objectclass=");
{
int rc = 0;
- switch (rewrite_session( dc->rw, dc->ctx, dn->bv_val, dc->conn,
+ switch (rewrite_session( dc->rwmap->rwm_rw, dc->ctx, dn->bv_val, dc->conn,
&res->bv_val )) {
case REWRITE_REGEXEC_OK:
if ( res->bv_val != NULL ) {
/*
* Cleanup rewrite session
*/
- rewrite_session_delete( li->rwinfo, conn );
+ rewrite_session_delete( li->rwmap.rwm_rw, conn );
#endif /* ENABLE_REWRITE */
/*