/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2005 The OpenLDAP Foundation.
+ * Copyright 1998-2006 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
{
struct ldapmapping *mapping;
- assert( m );
+ assert( m != NULL );
*m = NULL;
Avlnode *tree;
struct ldapmapping fmapping;
- assert( m );
+ assert( m != NULL );
if ( remap == BACKLDAP_REMAP ) {
tree = map->remap;
struct berval vtmp;
int freeval = 0;
- ldap_back_map( &dc->rwmap->rwm_at, &ad->ad_cname, mapped_attr, remap );
+ ldap_back_map( &dc->target->mt_rwmap.rwm_at, &ad->ad_cname, mapped_attr, remap );
if ( BER_BVISNULL( mapped_attr ) || BER_BVISEMPTY( mapped_attr ) ) {
+#if 0
/*
* FIXME: are we sure we need to search oc_map if at_map fails?
*/
- ldap_back_map( &dc->rwmap->rwm_oc, &ad->ad_cname, mapped_attr, remap );
+ ldap_back_map( &dc->target->mt_rwmap.rwm_oc, &ad->ad_cname, mapped_attr, remap );
if ( BER_BVISNULL( mapped_attr ) || BER_BVISEMPTY( mapped_attr ) ) {
*mapped_attr = ad->ad_cname;
}
+#endif
+ if ( dc->target->mt_rwmap.rwm_at.drop_missing ) {
+ return -1;
+ }
+
+ *mapped_attr = ad->ad_cname;
}
if ( value == NULL ) {
}
} else if ( ad == slap_schema.si_ad_objectClass || ad == slap_schema.si_ad_structuralObjectClass ) {
- ldap_back_map( &dc->rwmap->rwm_oc, value, &vtmp, remap );
+ ldap_back_map( &dc->target->mt_rwmap.rwm_oc, value, &vtmp, remap );
if ( BER_BVISNULL( &vtmp ) || BER_BVISEMPTY( &vtmp ) ) {
vtmp = *value;
}
{
int i;
Filter *p;
- struct berval atmp;
- struct berval vtmp;
+ struct berval atmp,
+ vtmp,
+ *tmp;
+ static struct berval
+ /* better than nothing... */
+ ber_bvfalse = BER_BVC( "(!(objectClass=*))" ),
+ ber_bvtf_false = BER_BVC( "(|)" ),
+ /* better than nothing... */
+ ber_bvtrue = BER_BVC( "(objectClass=*)" ),
+ ber_bvtf_true = BER_BVC( "(&)" ),
+#if 0
+ /* no longer needed; preserved for completeness */
+ ber_bvundefined = BER_BVC( "(?=undefined)" ),
+#endif
+ ber_bverror = BER_BVC( "(?=error)" ),
+ ber_bvunknown = BER_BVC( "(?=unknown)" ),
+ ber_bvnone = BER_BVC( "(?=none)" );
ber_len_t len;
if ( f == NULL ) {
- ber_str2bv( "No filter!", sizeof("No filter!")-1, 1, fstr );
- return -1;
+ ber_dupbv( fstr, &ber_bvnone );
+ return LDAP_OTHER;
}
switch ( f->f_choice ) {
if ( map_attr_value( dc, f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, remap ) )
{
- return -1;
+ goto computed;
}
fstr->bv_len = atmp.bv_len + vtmp.bv_len
if ( map_attr_value( dc, f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, remap ) )
{
- return -1;
+ goto computed;
}
fstr->bv_len = atmp.bv_len + vtmp.bv_len
if ( map_attr_value( dc, f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, remap ) )
{
- return -1;
+ goto computed;
}
fstr->bv_len = atmp.bv_len + vtmp.bv_len
if ( map_attr_value( dc, f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, remap ) )
{
- return -1;
+ goto computed;
}
fstr->bv_len = atmp.bv_len + vtmp.bv_len
if ( map_attr_value( dc, f->f_sub_desc, &atmp,
NULL, NULL, remap ) )
{
- return -1;
+ goto computed;
}
/* cannot be a DN ... */
if ( map_attr_value( dc, f->f_desc, &atmp,
NULL, NULL, remap ) )
{
- return -1;
+ goto computed;
}
fstr->bv_len = atmp.bv_len + ( STRLENOF( "(=*)" ) );
f->f_choice == LDAP_FILTER_OR ? '|' : '!' );
for ( p = f->f_list; p != NULL; p = p->f_next ) {
+ int rc;
+
len = fstr->bv_len;
- if ( ldap_back_int_filter_map_rewrite( dc, p, &vtmp, remap ) )
- {
- return -1;
+ rc = ldap_back_int_filter_map_rewrite( dc, p, &vtmp, remap );
+ if ( rc != LDAP_SUCCESS ) {
+ return rc;
}
fstr->bv_len += vtmp.bv_len;
break;
- case LDAP_FILTER_EXT: {
+ case LDAP_FILTER_EXT:
if ( f->f_mr_desc ) {
if ( map_attr_value( dc, f->f_mr_desc, &atmp,
&f->f_mr_value, &vtmp, remap ) )
{
- return -1;
+ goto computed;
}
} else {
!BER_BVISEMPTY( &f->f_mr_rule_text ) ? f->f_mr_rule_text.bv_val : "",
vtmp.bv_val );
ber_memfree( vtmp.bv_val );
- } break;
+ break;
case SLAPD_FILTER_COMPUTED:
switch ( f->f_result ) {
case LDAP_COMPARE_FALSE:
- ber_str2bv( "(?=false)", STRLENOF( "(?=false)" ), 1, fstr );
+ /* FIXME: treat UNDEFINED as FALSE */
+ case SLAPD_COMPARE_UNDEFINED:
+computed:;
+ if ( dc->target->mt_flags & LDAP_BACK_F_SUPPORT_T_F ) {
+ tmp = &ber_bvtf_false;
+ break;
+ }
+ tmp = &ber_bvfalse;
break;
+
case LDAP_COMPARE_TRUE:
- ber_str2bv( "(?=true)", STRLENOF( "(?=true)" ), 1, fstr );
- break;
- case SLAPD_COMPARE_UNDEFINED:
- ber_str2bv( "(?=undefined)", STRLENOF( "(?=undefined)" ), 1, fstr );
+ if ( dc->target->mt_flags & LDAP_BACK_F_SUPPORT_T_F ) {
+ tmp = &ber_bvtf_true;
+ break;
+ }
+
+ tmp = &ber_bvtrue;
break;
+
default:
- ber_str2bv( "(?=error)", STRLENOF( "(?=error)" ), 1, fstr );
+ tmp = &ber_bverror;
break;
}
+
+ ber_dupbv( fstr, tmp );
break;
default:
- ber_str2bv( "(?=unknown)", STRLENOF( "(?=unknown)" ), 1, fstr );
+ ber_dupbv( fstr, &ber_bvunknown );
break;
}
int rc;
dncookie fdc;
struct berval ftmp;
+ static char *dmy = "";
rc = ldap_back_int_filter_map_rewrite( dc, f, fstr, remap );
fdc.ctx = "searchFilter";
- switch ( rewrite_session( fdc.rwmap->rwm_rw, fdc.ctx,
- ( !BER_BVISEMPTY( &ftmp ) ? ftmp.bv_val : "" ),
+ switch ( rewrite_session( fdc.target->mt_rwmap.rwm_rw, fdc.ctx,
+ ( !BER_BVISEMPTY( &ftmp ) ? ftmp.bv_val : dmy ),
fdc.conn, &fstr->bv_val ) )
{
case REWRITE_REGEXEC_OK:
rc = LDAP_OTHER;
break;
}
+
+ if ( fstr->bv_val == dmy ) {
+ BER_BVZERO( fstr );
+ }
#endif /* ENABLE_REWRITE */
return rc;
{
int i, last;
- assert( dc );
- assert( a_vals );
+ assert( dc != NULL );
+ assert( a_vals != NULL );
for ( last = 0; !BER_BVISNULL( &a_vals[ last ] ); last++ )
;
ludp->lud_dn = dn.bv_val;
newurl = ldap_url_desc2str( ludp );
+ free( dn.bv_val );
if ( newurl == NULL ) {
/* FIXME: leave attr untouched
* even if ldap_url_desc2str failed...