+ /* Remove old rdn value if required */
+ if ( op->orr_deleteoldrdn ) {
+ for ( d_cnt = 0; old_rdn[d_cnt]; d_cnt++ ) {
+ AttributeDescription *desc = NULL;
+ Modifications *mod_tmp;
+
+ rs->sr_err = slap_bv2ad( &old_rdn[d_cnt]->la_attr, &desc, &rs->sr_text );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "slap_modrdn2modlist: %s: %s (old)\n",
+ rs->sr_text,
+ old_rdn[d_cnt]->la_attr.bv_val,
+ 0 );
+ goto done;
+ }
+
+ /* ACL check of old rdn attrs removal */
+ if ( op->o_bd && !access_allowed( op, e, desc,
+ &old_rdn[d_cnt]->la_value, ACL_WDEL,
+ NULL ) ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "slap_modrdn2modlist: access "
+ "to attr \"%s\" (old) not allowed\n",
+ old_rdn[ d_cnt ]->la_attr.bv_val,
+ 0, 0 );
+ rs->sr_text = "access to naming attributes (old) not allowed";
+ rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+ goto done;
+ }
+
+ /* Apply modification */
+ mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
+ + 4 * sizeof ( struct berval ) );
+ mod_tmp->sml_desc = desc;
+ mod_tmp->sml_values = ( BerVarray )(mod_tmp+1);
+ mod_tmp->sml_values[0] = old_rdn[d_cnt]->la_value;
+ mod_tmp->sml_values[1].bv_val = NULL;
+ if( desc->ad_type->sat_equality->smr_normalize) {
+ mod_tmp->sml_nvalues = &mod_tmp->sml_values[2];
+ (void) (*desc->ad_type->sat_equality->smr_normalize)(
+ SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
+ desc->ad_type->sat_syntax,
+ desc->ad_type->sat_equality,
+ &mod_tmp->sml_values[0],
+ &mod_tmp->sml_nvalues[0], op->o_tmpmemctx );
+ mod_tmp->sml_nvalues[1].bv_val = NULL;
+ } else {
+ mod_tmp->sml_nvalues = NULL;
+ }
+ mod_tmp->sml_op = LDAP_MOD_DELETE;
+ mod_tmp->sml_flags = SLAP_MOD_INTERNAL;
+ mod_tmp->sml_next = mod;
+ mod = mod_tmp;
+ }
+ }
+
+done:
+
+ if ( rs->sr_err == LDAP_SUCCESS && !repl_user ) {
+ slap_mods_opattrs( op, &mod, 1 );
+ }
+
+ /* LDAP v2 supporting correct attribute handling. */
+ if ( rs->sr_err != LDAP_SUCCESS && mod != NULL ) {
+ Modifications *tmp;
+ for ( ; mod; mod = tmp ) {
+ tmp = mod->sml_next;
+ ch_free( mod );
+ }
+ }
+
+ *pmod = mod;
+
+ return rs->sr_err;
+}
+
+void
+slap_modrdn2mods_free( Modifications *mod )
+{
+ Modifications *tmp;
+
+ for ( ; mod; mod = tmp ) {
+ tmp = mod->sml_next;
+ /* slap_modrdn2mods does things one way,
+ * slap_mods_opattrs does it differently
+ */
+ if ( mod->sml_op != SLAP_MOD_SOFTADD &&
+ mod->sml_op != LDAP_MOD_DELETE )
+ {
+ break;
+ }
+
+ if ( mod->sml_nvalues ) {
+ free( mod->sml_nvalues[0].bv_val );
+ }
+
+ free( mod );
+ }
+
+ slap_mods_free( mod, 1 );