/* 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
- == slap_schema.si_syn_distinguishedName )
+ if ( (*ap)->a_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName
+ || ( mapping != NULL && mapping->m_dst_ad->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) )
{
/*
* FIXME: rewrite could fail; in this case
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;
}
- if ( op->orc_ava->aa_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName )
+ if ( op->orc_ava->aa_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName
+ || ( mapping != NULL && mapping->m_dst_ad->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) )
{
struct berval *mapped_valsp[2];
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 ) {
last--;
for ( j = 0; !BER_BVISNULL( &(*mlp)->sml_values[ j ] ); j++ ) {
- struct ldapmapping *mapping = NULL;
-
+ struct ldapmapping *oc_mapping = NULL;
+
( void )rwm_mapping( &rwmap->rwm_oc, &(*mlp)->sml_values[ j ],
- &mapping, RWM_MAP );
- if ( mapping == NULL ) {
+ &oc_mapping, RWM_MAP );
+ if ( oc_mapping == NULL ) {
if ( rwmap->rwm_at.drop_missing ) {
/* FIXME: we allow to remove objectClasses as well;
* if the resulting entry is inconsistent, that's
} else {
ch_free( (*mlp)->sml_values[ j ].bv_val );
- ber_dupbv( &(*mlp)->sml_values[ j ], &mapping->m_dst );
+ ber_dupbv( &(*mlp)->sml_values[ j ], &oc_mapping->m_dst );
}
}
} else {
- if ( (*mlp)->sml_desc->ad_type->sat_syntax ==
- slap_schema.si_syn_distinguishedName )
+ if ( (*mlp)->sml_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName
+ || ( mapping != NULL && mapping->m_dst_ad->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) )
{
#ifdef ENABLE_REWRITE
rc = rwm_dnattr_rewrite( op, rs, "modifyAttrDN",
}
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;
free( ml );
}
- /* TODO: rewrite attribute types, values of DN-valued attributes ... */
return SLAP_CB_CONTINUE;
}
}
static int
-rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first )
+rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first, int stripEntryDN )
{
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
struct ldaprwmap *rwmap =
* about duplicate values?) */
isupdate = be_shadow_update( op );
for ( ap = a_first; *ap; ) {
- struct ldapmapping *m;
+ struct ldapmapping *mapping = NULL;
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 ) )
- {
- goto cleanup_attr;
+ } else {
+ if ( op->ors_attrs != NULL &&
+ !SLAP_USERATTRS( rs->sr_attr_flags ) &&
+ !ad_inlist( (*ap)->a_desc, op->ors_attrs ) )
+ {
+ goto cleanup_attr;
+ }
+
+ 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 ( !isupdate && (*ap)->a_desc->ad_type->sat_no_user_mod
+ if ( (*ap)->a_desc == slap_schema.si_ad_entryDN ) {
+ if ( stripEntryDN ) {
+ /* will be generated by frontend */
+ goto cleanup_attr;
+ }
+
+ } else if ( !isupdate
+ && (*ap)->a_desc->ad_type->sat_no_user_mod
&& (*ap)->a_desc->ad_type != slap_schema.si_at_undefined )
{
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 */ ;
* everything pass thru the ldap backend. */
/* FIXME: handle distinguishedName-like syntaxes, like
* nameAndOptionalUID */
- } else if ( (*ap)->a_desc->ad_type->sat_syntax ==
- slap_schema.si_syn_distinguishedName )
+ } else if ( (*ap)->a_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName
+ || ( mapping != NULL && mapping->m_src_ad->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) )
{
#ifdef ENABLE_REWRITE
dc.ctx = "searchAttrDN";
}
}
- 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:;
/* FIXME: the entries are in the remote mapping form;
* so we need to select those attributes we are willing
* to return, and remap them accordingly */
- (void)rwm_attrs( op, rs, &e->e_attrs );
+ (void)rwm_attrs( op, rs, &e->e_attrs, 1 );
+
+#if 0
+ if ( rs->sr_operational_attrs ) {
+ (void)rwm_attrs( op, rs, &rs->sr_operational_attrs, 0 );
+ }
+#endif
rs->sr_entry = e;
rs->sr_flags = flags;
* so we need to select those attributes we are willing
* to return, and remap them accordingly */
if ( rs->sr_operational_attrs ) {
- rwm_attrs( op, rs, &rs->sr_operational_attrs );
+ rwm_attrs( op, rs, &rs->sr_operational_attrs, 1 );
}
return SLAP_CB_CONTINUE;
switch( op->o_tag ) {
case LDAP_REQ_SEARCH:
/* Note: the operation attrs are remapped */
- if ( op->ors_attrs != NULL && op->ors_attrs != rs->sr_attrs )
+ if ( rs->sr_type == REP_RESULT
+ && op->ors_attrs != NULL
+ && op->ors_attrs != rs->sr_attrs )
{
ch_free( op->ors_attrs );
op->ors_attrs = rs->sr_attrs;