- goto cleanup;
- }
-
- if ( rc == LDAP_SUCCESS ) {
- for ( i = 0, pMod = mods[0]; rc == LDAP_SUCCESS && pMod != NULL; pMod = mods[++i]) {
- Modifications *mod;
-
- if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) {
- /*
- * Convert an array of pointers to bervals to
- * an array of bervals. Note that we need to copy the
- * values too, as the slap_mods_check() will free the
- * original values after prettying; the modifications
- * being passed in may not have been allocated on the
- * heap.
- */
- rc = bvptr2obj_copy( pMod->mod_bvalues, &bv );
- if ( rc != LDAP_SUCCESS ) goto cleanup;
- tmp.sml_type.bv_val = pMod->mod_type;
- tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_values = bv;
- tmp.sml_nvalues = NULL;
-
- mod = (Modifications *) ch_malloc( sizeof(Modifications) );
-
- mod->sml_op = LDAP_MOD_ADD;
- mod->sml_flags = 0;
- mod->sml_next = NULL;
- mod->sml_desc = NULL;
- mod->sml_type = tmp.sml_type;
- mod->sml_values = tmp.sml_values;
- mod->sml_nvalues = tmp.sml_nvalues;
-
- *modtail = mod;
- modtail = &mod->sml_next;
-
- } else {
- /* attr values are in string format, need to be converted */
- /* to an array of bervals */
- if ( pMod->mod_values == NULL ) {
- rc = LDAP_OTHER;
- } else {
- rc = values2obj_copy( pMod->mod_values, &bv );
- if ( rc != LDAP_SUCCESS ) goto cleanup;
- tmp.sml_type.bv_val = pMod->mod_type;
- tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_values = bv;
- tmp.sml_nvalues = NULL;
-
- mod = (Modifications *) ch_malloc( sizeof(Modifications) );
-
- mod->sml_op = LDAP_MOD_ADD;
- mod->sml_flags = 0;
- mod->sml_next = NULL;
- mod->sml_desc = NULL;
- mod->sml_type = tmp.sml_type;
- mod->sml_values = tmp.sml_values;
- mod->sml_nvalues = tmp.sml_nvalues;
-
- *modtail = mod;
- modtail = &mod->sml_next;
- }
- }
- } /* for each LDAPMod */
- }
-
- op->o_bd = select_backend( &pEntry->e_nname, 0, 0 );
- if ( op->o_bd == NULL ) {
- rc = LDAP_PARTIAL_RESULTS;
- } else {
- int repl_user = be_isupdate_dn( op->o_bd, &op->o_bd->be_rootdn );
- if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
- int update = !BER_BVISNULL( &op->o_bd->be_update_ndn );
- char textbuf[ SLAP_TEXT_BUFLEN ];
- size_t textlen = sizeof( textbuf );
-
- rc = slap_mods_check( modlist, &text,
- textbuf, textlen, NULL );
-
- if ( rc != LDAP_SUCCESS) {
- goto cleanup;
- }
-
- if ( !update ) {
- rc = slap_mods_no_user_mod_check( op, modlist,
- &text, textbuf, textlen );
- if ( rc != LDAP_SUCCESS) {
- goto cleanup;
- }
- }
-
- if ( !repl_user ) {
- rc = slap_mods_opattrs( op, modlist, modtail,
- &text, textbuf, textlen, 1 );
- if ( rc != LDAP_SUCCESS) {
- goto cleanup;
- }
- }
-
- rc = slap_mods2entry( modlist, &pEntry, repl_user,
- 0, &text, textbuf, textlen );
- if (rc != LDAP_SUCCESS) {
- goto cleanup;
- }
-
- } else {
- rc = LDAP_REFERRAL;
- }