improve previous commit; implement missing objectClass mapping feature

This commit is contained in:
Pierangelo Masarati 2005-01-20 18:39:51 +00:00
parent 64668f7207
commit 0057b66f87
2 changed files with 52 additions and 25 deletions

View file

@ -108,8 +108,8 @@ meta_back_add( Operation *op, SlapReply *rs )
* to allow their use in ACLs at the back-ldap * to allow their use in ACLs at the back-ldap
* level. * level.
*/ */
if ( strcmp( a->a_desc->ad_type->sat_syntax->ssyn_oid, if ( a->a_desc->ad_type->sat_syntax ==
SLAPD_DN_SYNTAX ) == 0 ) slap_schema.si_syn_distinguishedName )
{ {
(void)ldap_dnattr_rewrite( &dc, a->a_vals ); (void)ldap_dnattr_rewrite( &dc, a->a_vals );
} }

View file

@ -97,18 +97,26 @@ meta_back_modify( Operation *op, SlapReply *rs )
dc.ctx = "modifyAttrDN"; dc.ctx = "modifyAttrDN";
isupdate = be_shadow_update( op ); isupdate = be_shadow_update( op );
for ( i = 0, ml = op->orm_modlist; ml; ml = ml->sml_next ) { for ( i = 0, ml = op->orm_modlist; ml; ml = ml->sml_next ) {
int j; int j, is_oc = 0;
if ( !isupdate && ml->sml_desc->ad_type->sat_no_user_mod ) { if ( !isupdate && ml->sml_desc->ad_type->sat_no_user_mod ) {
continue; 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->targets[ candidate ]->mt_rwmap.rwm_at, ldap_back_map( &li->targets[ candidate ]->mt_rwmap.rwm_at,
&ml->sml_desc->ad_cname, &mapped, &ml->sml_desc->ad_cname, &mapped,
BACKLDAP_MAP ); BACKLDAP_MAP );
if ( BER_BVISNULL( &mapped ) || BER_BVISEMPTY( &mapped ) ) { if ( BER_BVISNULL( &mapped ) || BER_BVISEMPTY( &mapped ) ) {
continue; continue;
} }
}
modv[ i ] = &mods[ i ]; modv[ i ] = &mods[ i ];
mods[ i ].mod_op = ml->sml_op | LDAP_MOD_BVALUES; mods[ i ].mod_op = ml->sml_op | LDAP_MOD_BVALUES;
@ -120,14 +128,34 @@ meta_back_modify( Operation *op, SlapReply *rs )
* level. * level.
*/ */
if ( ml->sml_values != NULL ) { if ( ml->sml_values != NULL ) {
/* mod_op must be delete all values */ if ( is_oc ) {
if ( strcmp( ml->sml_desc->ad_type->sat_syntax->ssyn_oid, for ( j = 0; !BER_BVISNULL( &ml->sml_values[ j ] ); j++ )
SLAPD_DN_SYNTAX ) == 0 ) ;
mods[ i ].mod_bvalues =
(struct berval **)ch_malloc( ( j + 1 ) *
sizeof( struct berval * ) );
for ( j = 0; !BER_BVISNULL( &ml->sml_values[ j ] ); j++ ) {
ldap_back_map( &li->targets[ candidate ]->mt_rwmap.rwm_oc,
&ml->sml_values[ j ],
&mapped, BACKLDAP_MAP );
if ( BER_BVISNULL( &mapped ) || BER_BVISEMPTY( &mapped ) )
{
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 )
{ {
( void )ldap_dnattr_rewrite( &dc, ml->sml_values ); ( void )ldap_dnattr_rewrite( &dc, ml->sml_values );
if ( ml->sml_values == NULL ) {
continue;
}
} }
if ( ml->sml_values != NULL ) {
for ( j = 0; !BER_BVISNULL( &ml->sml_values[ j ] ); j++ ) for ( j = 0; !BER_BVISNULL( &ml->sml_values[ j ] ); j++ )
; ;
mods[ i ].mod_bvalues = mods[ i ].mod_bvalues =
@ -147,8 +175,8 @@ meta_back_modify( Operation *op, SlapReply *rs )
} }
modv[ i ] = 0; modv[ i ] = 0;
rc = ldap_modify_ext_s( lc->mc_conns[ candidate ].msc_ld, mdn.bv_val, rs->sr_err = ldap_modify_ext_s( lc->mc_conns[ candidate ].msc_ld, mdn.bv_val,
modv, NULL, NULL ) != LDAP_SUCCESS; modv, NULL, NULL );
cleanup:; cleanup:;
if ( mdn.bv_val != op->o_req_dn.bv_val ) { if ( mdn.bv_val != op->o_req_dn.bv_val ) {
@ -163,13 +191,12 @@ cleanup:;
free( mods ); free( mods );
free( modv ); free( modv );
if ( rc == 0 ) { if ( rc != -1 ) {
return meta_back_op_result( lc, op, rs ) == LDAP_SUCCESS return meta_back_op_result( lc, op, rs );
? 0 : 1; }
} /* else */
send_ldap_result( op, rs ); send_ldap_result( op, rs );
return rc; return rs->sr_err;
} }