/* Count number of attributes in entry */
isupdate = be_shadow_update( op );
for ( i = 0, ap = &op->oq_add.rs_e->e_attrs; *ap; ) {
- struct berval mapped;
Attribute *a;
if ( (*ap)->a_desc == slap_schema.si_ad_objectClass ||
if ( rwmap->rwm_at.drop_missing ) {
goto cleanup_attr;
}
-
- } else {
- (*ap)->a_desc = mapping->m_dst_ad;
}
if ( (*ap)->a_desc->ad_type->sat_syntax
goto cleanup_attr;
}
}
+
+ if ( mapping != NULL ) {
+ assert( mapping->m_dst_ad );
+ (*ap)->a_desc = mapping->m_dst_ad;
+ }
}
next_attr:;
}
} else {
+ assert( mapping->m_dst_ad );
ad = mapping->m_dst_ad;
}
isupdate = be_shadow_update( op );
for ( mlp = &op->oq_modify.rs_modlist; *mlp; ) {
- int is_oc = 0;
- Modifications *ml;
+ int is_oc = 0;
+ Modifications *ml;
+ struct ldapmapping *mapping = NULL;
if ( (*mlp)->sml_desc == slap_schema.si_ad_objectClass
|| (*mlp)->sml_desc == slap_schema.si_ad_structuralObjectClass )
goto next_mod;
} else {
- struct ldapmapping *m;
int drop_missing;
- drop_missing = rwm_mapping( &rwmap->rwm_at, &(*mlp)->sml_desc->ad_cname, &m, RWM_MAP );
- if ( drop_missing || ( m != NULL && BER_BVISNULL( &m->m_dst ) ) )
+ drop_missing = rwm_mapping( &rwmap->rwm_at,
+ &(*mlp)->sml_desc->ad_cname,
+ &mapping, RWM_MAP );
+ if ( drop_missing || ( mapping != NULL && BER_BVISNULL( &mapping->m_dst ) ) )
{
goto cleanup_mod;
}
-
- if ( m ) {
- /* use new attribute description */
- assert( m->m_dst_ad );
- (*mlp)->sml_desc = m->m_dst_ad;
- }
}
if ( (*mlp)->sml_values != NULL ) {
}
next_mod:;
+ if ( mapping != NULL ) {
+ /* use new attribute description */
+ assert( mapping->m_dst_ad );
+ (*mlp)->sml_desc = mapping->m_dst_ad;
+ }
+
mlp = &(*mlp)->sml_next;
continue;
* about duplicate values?) */
isupdate = be_shadow_update( op );
for ( ap = a_first; *ap; ) {
- struct ldapmapping *m;
+ struct ldapmapping *mapping;
int drop_missing;
int last;
Attribute *a;
{
/* go on */ ;
- } else if ( op->ors_attrs != NULL &&
- !SLAP_USERATTRS( rs->sr_attr_flags ) &&
- !ad_inlist( (*ap)->a_desc, op->ors_attrs ) )
- {
+ } else {
+ drop_missing = rwm_mapping( &rwmap->rwm_at,
+ &(*ap)->a_desc->ad_cname, &mapping, RWM_REMAP );
+ if ( drop_missing || ( mapping != NULL && BER_BVISEMPTY( &mapping->m_dst ) ) )
+ {
+ goto cleanup_attr;
+ }
+
+ if ( mapping != NULL ) {
+ (*ap)->a_desc = mapping->m_dst_ad;
+ }
+
+ if ( op->ors_attrs != NULL &&
+ !SLAP_USERATTRS( rs->sr_attr_flags ) &&
+ !ad_inlist( (*ap)->a_desc, op->ors_attrs ) )
+ {
+ goto cleanup_attr;
+ }
+ }
+
+ if ( (*ap)->a_desc == slap_schema.si_ad_entryDN ) {
+ /* will be generated by frontend */
goto cleanup_attr;
}
goto next_attr;
}
- drop_missing = rwm_mapping( &rwmap->rwm_at,
- &(*ap)->a_desc->ad_cname, &m, RWM_REMAP );
- if ( drop_missing || ( m != NULL && BER_BVISEMPTY( &m->m_dst ) ) ) {
- goto cleanup_attr;
- }
-
for ( last = 0; !BER_BVISNULL( &(*ap)->a_vals[last] ); last++ )
/* just count */ ;
}
}
- if ( m != NULL ) {
+ if ( mapping != NULL ) {
/* rewrite the attribute description */
- assert( m->m_dst_ad );
- (*ap)->a_desc = m->m_dst_ad;
+ assert( mapping->m_dst_ad );
+ (*ap)->a_desc = mapping->m_dst_ad;
}
next_attr:;
return LDAP_SUCCESS;
}
- for ( i = 0; !BER_BVISNULL( &an[i].an_name ); i++ ) {
+ for ( i = 0; !BER_BVISNULL( &an[ i ].an_name ); i++ ) {
/* */
}
na = (char **)ch_calloc( i + 1, sizeof( char * ) );
- if (na == NULL) {
+ if ( na == NULL ) {
*mapped_attrs = NULL;
return LDAP_NO_MEMORY;
}
for ( i = j = 0; !BER_BVISNULL( &an[i].an_name ); i++ ) {
- struct ldapmapping *m;
+ struct ldapmapping *mapping;
- if ( rwm_mapping( at_map, &an[i].an_name, &m, remap ) ) {
+ if ( rwm_mapping( at_map, &an[i].an_name, &mapping, remap ) ) {
continue;
}
- if ( !m || ( m && !BER_BVISNULL( &m->m_dst ) ) ) {
- na[j++] = m->m_dst.bv_val;
+ if ( !mapping ) {
+ na[ j++ ] = an[ i ].an_name.bv_val;
+
+ } else if ( !BER_BVISNULL( &mapping->m_dst ) ) {
+ na[ j++ ] = mapping->m_dst.bv_val;
}
}
+
if ( j == 0 && i != 0 ) {
- na[j++] = LDAP_NO_ATTRS;
+ na[ j++ ] = LDAP_NO_ATTRS;
}
- na[j] = NULL;
+
+ na[ j ] = NULL;
*mapped_attrs = na;
+
return LDAP_SUCCESS;
}
static int
map_attr_value(
dncookie *dc,
- AttributeDescription *ad,
+ AttributeDescription **adp,
struct berval *mapped_attr,
struct berval *value,
struct berval *mapped_value,
{
struct berval vtmp = BER_BVNULL;
int freeval = 0;
+ AttributeDescription *ad = *adp;
+ struct ldapmapping *mapping = NULL;
- rwm_map( &dc->rwmap->rwm_at, &ad->ad_cname, mapped_attr, remap );
- if ( BER_BVISNULL( mapped_attr ) || BER_BVISEMPTY( mapped_attr ) ) {
- /*
- * FIXME: are we sure we need to search oc_map if at_map fails?
- */
- rwm_map( &dc->rwmap->rwm_oc, &ad->ad_cname, mapped_attr, remap );
- if ( BER_BVISNULL( mapped_attr ) || BER_BVISEMPTY( mapped_attr ) )
- {
- *mapped_attr = ad->ad_cname;
+ rwm_mapping( &dc->rwmap->rwm_at, &ad->ad_cname, &mapping, remap );
+ if ( mapping == NULL ) {
+ if ( dc->rwmap->rwm_at.drop_missing ) {
+ return -1;
}
- }
- if ( value == NULL ) {
- return 0;
+ *mapped_attr = ad->ad_cname;
+
+ } else {
+ *mapped_attr = mapping->m_dst;
}
- if ( ad->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName )
- {
- dncookie fdc = *dc;
- int rc;
+ if ( value != NULL ) {
+ assert( mapped_value != NULL );
+
+ if ( ad->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName )
+ {
+ dncookie fdc = *dc;
+ int rc;
#ifdef ENABLE_REWRITE
- fdc.ctx = "searchFilterAttrDN";
+ fdc.ctx = "searchFilterAttrDN";
#endif /* ENABLE_REWRITE */
- vtmp = *value;
- rc = rwm_dn_massage_normalize( &fdc, value, &vtmp );
- switch ( rc ) {
- case LDAP_SUCCESS:
- if ( vtmp.bv_val != value->bv_val ) {
- freeval = 1;
- }
- break;
+ vtmp = *value;
+ rc = rwm_dn_massage_normalize( &fdc, value, &vtmp );
+ switch ( rc ) {
+ case LDAP_SUCCESS:
+ if ( vtmp.bv_val != value->bv_val ) {
+ freeval = 1;
+ }
+ break;
- case LDAP_UNWILLING_TO_PERFORM:
- case LDAP_OTHER:
- default:
- return -1;
- }
+ case LDAP_UNWILLING_TO_PERFORM:
+ case LDAP_OTHER:
+ default:
+ return -1;
+ }
- } else if ( ad == slap_schema.si_ad_objectClass
- || ad == slap_schema.si_ad_structuralObjectClass )
- {
- rwm_map( &dc->rwmap->rwm_oc, value, &vtmp, remap );
- if ( BER_BVISNULL( &vtmp ) || BER_BVISEMPTY( &vtmp ) ) {
+ } else if ( ad == slap_schema.si_ad_objectClass
+ || ad == slap_schema.si_ad_structuralObjectClass )
+ {
+ rwm_map( &dc->rwmap->rwm_oc, value, &vtmp, remap );
+ if ( BER_BVISNULL( &vtmp ) || BER_BVISEMPTY( &vtmp ) ) {
+ vtmp = *value;
+ }
+
+ } else {
vtmp = *value;
}
-
- } else {
- vtmp = *value;
- }
- filter_escape_value( &vtmp, mapped_value );
+ filter_escape_value( &vtmp, mapped_value );
- if ( freeval ) {
- ch_free( vtmp.bv_val );
+ if ( freeval ) {
+ ch_free( vtmp.bv_val );
+ }
}
+ if ( mapping != NULL ) {
+ assert( mapping->m_dst_ad != NULL );
+ *adp = mapping->m_dst_ad;
+ }
+
return 0;
}
switch ( f->f_choice ) {
case LDAP_FILTER_EQUALITY:
- if ( map_attr_value( dc, f->f_av_desc, &atmp,
+ if ( map_attr_value( dc, &f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, RWM_MAP ) )
{
return -1;
break;
case LDAP_FILTER_GE:
- if ( map_attr_value( dc, f->f_av_desc, &atmp,
+ if ( map_attr_value( dc, &f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, RWM_MAP ) )
{
return -1;
break;
case LDAP_FILTER_LE:
- if ( map_attr_value( dc, f->f_av_desc, &atmp,
+ if ( map_attr_value( dc, &f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, RWM_MAP ) )
{
return -1;
break;
case LDAP_FILTER_APPROX:
- if ( map_attr_value( dc, f->f_av_desc, &atmp,
+ if ( map_attr_value( dc, &f->f_av_desc, &atmp,
&f->f_av_value, &vtmp, RWM_MAP ) )
{
return -1;
break;
case LDAP_FILTER_SUBSTRINGS:
- if ( map_attr_value( dc, f->f_sub_desc, &atmp,
+ if ( map_attr_value( dc, &f->f_sub_desc, &atmp,
NULL, NULL, RWM_MAP ) )
{
return -1;
break;
case LDAP_FILTER_PRESENT:
- if ( map_attr_value( dc, f->f_desc, &atmp,
+ if ( map_attr_value( dc, &f->f_desc, &atmp,
NULL, NULL, RWM_MAP ) )
{
return -1;
case LDAP_FILTER_EXT: {
if ( f->f_mr_desc ) {
- if ( map_attr_value( dc, f->f_mr_desc, &atmp,
+ if ( map_attr_value( dc, &f->f_mr_desc, &atmp,
&f->f_mr_value, &vtmp, RWM_MAP ) )
{
return -1;