1 /* modrdn.c - bdb backend modrdn routine */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/string.h>
23 struct berval *newrdn,
24 struct berval *nnewrdn,
26 struct berval *newSuperior,
27 struct berval *nnewSuperior )
29 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
30 AttributeDescription *children = slap_schema.si_ad_children;
31 struct berval p_dn, p_ndn;
32 struct berval new_dn = {0, NULL}, new_ndn = {0, NULL};
39 char textbuf[SLAP_TEXT_BUFLEN];
40 size_t textlen = sizeof textbuf;
42 struct bdb_op_info opinfo;
46 LDAPRDN *new_rdn = NULL;
47 LDAPRDN *old_rdn = NULL;
49 Entry *np = NULL; /* newSuperior Entry */
50 struct berval *np_dn = NULL; /* newSuperior dn */
51 struct berval *np_ndn = NULL; /* newSuperior ndn */
52 struct berval *new_parent_dn = NULL; /* np_dn, p_dn, or NULL */
54 /* Used to interface with bdb_modify_internal() */
55 Modifications *mod = NULL; /* Used to delete old rdn */
57 int manageDSAit = get_manageDSAit( op );
60 LDAP_LOG (( "modrdn", LDAP_LEVEL_ENTRY, "==>bdb_modrdn(%s,%s,%s)\n",
61 dn->bv_val,newrdn->bv_val,
62 newSuperior ? newSuperior->bv_val : "NULL" ));
64 Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn(%s,%s,%s)\n",
65 dn->bv_val, newrdn->bv_val,
66 newSuperior ? newSuperior->bv_val : "NULL" );
70 if( newSuperior != NULL ) {
71 rc = LDAP_UNWILLING_TO_PERFORM;
72 text = "newSuperior not implemented (yet)";
78 retry: /* transaction retry */
80 bdb_cache_delete_entry(&bdb->bi_cache, e);
81 bdb_cache_return_entry_w(&bdb->bi_cache, e);
84 bdb_cache_return_entry_r(&bdb->bi_cache, p);
87 bdb_cache_return_entry_r(&bdb->bi_cache, np);
90 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: retrying...\n"));
92 Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn: retrying...\n", 0, 0, 0 );
94 rc = TXN_ABORT( ltid );
99 text = "internal error";
102 ldap_pvt_thread_yield();
105 /* begin transaction */
106 rc = TXN_BEGIN( bdb->bi_dbenv, NULL, <id,
107 bdb->bi_db_opflags );
111 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: txn_begin failed: %s (%d)\n", db_strerror(rc), rc ));
113 Debug( LDAP_DEBUG_TRACE,
114 "bdb_delete: txn_begin failed: %s (%d)\n",
115 db_strerror(rc), rc, 0 );
118 text = "internal error";
123 opinfo.boi_txn = ltid;
125 op->o_private = &opinfo;
128 rc = bdb_dn2entry_w( be, ltid, ndn, &e, &matched, 0 );
134 case DB_LOCK_DEADLOCK:
135 case DB_LOCK_NOTGRANTED:
138 text = "ldap server busy";
142 text = "internal error";
147 char* matched_dn = NULL;
150 if( matched != NULL ) {
151 matched_dn = ch_strdup( matched->e_dn );
152 refs = is_entry_referral( matched )
153 ? get_entry_referrals( be, conn, op, matched )
155 bdb_cache_return_entry_r( &bdb->bi_cache, matched );
159 refs = referral_rewrite( default_referral,
160 NULL, dn, LDAP_SCOPE_DEFAULT );
163 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
164 matched_dn, NULL, refs, NULL );
166 ber_bvarray_free( refs );
172 if (!manageDSAit && is_entry_referral( e ) ) {
173 /* parent is a referral, don't allow add */
174 /* parent is an alias, don't allow add */
175 BerVarray refs = get_entry_referrals( be,
179 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: entry %s is referral \n", e->e_dn ));
181 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n",
185 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
186 e->e_dn, NULL, refs, NULL );
188 ber_bvarray_free( refs );
192 if ( be_issuffix( be, &e->e_nname ) ) {
193 p_ndn = slap_empty_bv;
195 dnParent( &e->e_nname, &p_ndn );
198 if ( p_ndn.bv_len != 0 ) {
199 /* Make sure parent entry exist and we can write its
202 rc = bdb_dn2entry_r( be, ltid, &p_ndn, &p, NULL, 0 );
208 case DB_LOCK_DEADLOCK:
209 case DB_LOCK_NOTGRANTED:
212 text = "ldap server busy";
216 text = "internal error";
222 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: parent does not exist\n" ));
224 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: parent does not exist\n",
231 /* check parent for "children" acl */
232 if ( ! access_allowed( be, conn, op, p,
233 children, NULL, ACL_WRITE, NULL ) )
236 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: no access to parent\n" ));
238 Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0,
241 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
242 NULL, NULL, NULL, NULL );
247 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: wr to children %s is OK\n", p_ndn.bv_val ));
249 Debug( LDAP_DEBUG_TRACE,
250 "bdb_modrdn: wr to children of entry %s OK\n",
251 p_ndn.bv_val, 0, 0 );
254 if ( p_ndn.bv_val == slap_empty_bv.bv_val ) {
255 p_dn = slap_empty_bv;
257 dnParent( &e->e_name, &p_dn );
261 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: parent dn=%s\n", p_dn.bv_val ));
263 Debug( LDAP_DEBUG_TRACE,
264 "bdb_modrdn: parent dn=%s\n",
269 /* no parent, modrdn entry directly under root */
270 isroot = be_isroot( be, &op->o_ndn );
272 if ( be_issuffix( be, (struct berval *)&slap_empty_bv )
273 || be_isupdate( be, &op->o_ndn ) ) {
275 p = (Entry *)&slap_entry_root;
277 /* check parent for "children" acl */
278 rc = access_allowed( be, conn, op, p,
279 children, NULL, ACL_WRITE, NULL );
286 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: no access to parent\n" ));
288 Debug( LDAP_DEBUG_TRACE,
289 "no access to parent\n",
292 send_ldap_result( conn, op,
293 LDAP_INSUFFICIENT_ACCESS,
294 NULL, NULL, NULL, NULL );
299 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: wr to children of entry \"\" OK\n", p_dn.bv_val ));
301 Debug( LDAP_DEBUG_TRACE,
302 "bdb_modrdn: wr to children of entry \"\" OK\n",
310 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: parent dn=\"\" \n" ));
312 Debug( LDAP_DEBUG_TRACE,
313 "bdb_modrdn: parent dn=\"\"\n",
319 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: no parent, not root &\"\" is not suffix\n" ));
321 Debug( LDAP_DEBUG_TRACE,
322 "bdb_modrdn: no parent, not root "
323 "& \"\" is not suffix\n",
326 rc = LDAP_INSUFFICIENT_ACCESS;
332 new_parent_dn = &p_dn; /* New Parent unless newSuperior given */
334 if ( newSuperior != NULL ) {
336 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: new parent \"%s\" requested...\n", newSuperior->bv_val ));
338 Debug( LDAP_DEBUG_TRACE,
339 "bdb_modrdn: new parent \"%s\" requested...\n",
340 newSuperior->bv_val, 0, 0 );
343 if ( newSuperior->bv_len ) {
345 np_ndn = nnewSuperior;
347 /* newSuperior == oldParent?, if so ==> ERROR */
348 /* newSuperior == entry being moved?, if so ==> ERROR */
349 /* Get Entry with dn=newSuperior. Does newSuperior exist? */
351 rc = bdb_dn2entry_r( be, ltid, nnewSuperior, &np, NULL, 0 );
357 case DB_LOCK_DEADLOCK:
358 case DB_LOCK_NOTGRANTED:
361 text = "ldap server busy";
365 text = "internal error";
371 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: newSup(ndn=%s) not here!\n", np_ndn->bv_val ));
373 Debug( LDAP_DEBUG_TRACE,
374 "bdb_modrdn: newSup(ndn=%s) not here!\n",
375 np_ndn->bv_val, 0, 0);
382 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: wr to new parent OK np=%p, id=%ld\n", np, (long) np->e_id ));
384 Debug( LDAP_DEBUG_TRACE,
385 "bdb_modrdn: wr to new parent OK np=%p, id=%ld\n",
386 np, (long) np->e_id, 0 );
389 /* check newSuperior for "children" acl */
390 if ( !access_allowed( be, conn, op, np, children, NULL, ACL_WRITE, NULL ) ) {
392 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: no wr to newSup children\n" ));
394 Debug( LDAP_DEBUG_TRACE,
395 "bdb_modrdn: no wr to newSup children\n",
398 rc = LDAP_INSUFFICIENT_ACCESS;
403 if ( is_entry_alias( np ) ) {
404 /* parent is an alias, don't allow add */
406 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: entry is alias\n" ));
408 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is alias\n",
412 rc = LDAP_ALIAS_PROBLEM;
417 if ( is_entry_referral( np ) ) {
418 /* parent is a referral, don't allow add */
420 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: entry is referral\n" ));
422 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is referral\n",
426 rc = LDAP_OPERATIONS_ERROR;
431 if ( isroot == -1 ) {
432 isroot = be_isroot( be, &op->o_ndn );
437 /* no parent, modrdn entry directly under root */
439 if ( be_issuffix( be, (struct berval *)&slap_empty_bv )
440 || be_isupdate( be, &op->o_ndn ) ) {
441 np = (Entry *)&slap_entry_root;
443 /* check parent for "children" acl */
444 rc = access_allowed( be, conn, op, np,
445 children, NULL, ACL_WRITE, NULL );
452 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: no access to superior\n" ));
454 Debug( LDAP_DEBUG_TRACE,
455 "no access to new superior\n",
458 send_ldap_result( conn, op,
459 LDAP_INSUFFICIENT_ACCESS,
460 NULL, NULL, NULL, NULL );
465 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "bdb_modrdn: wr to children entry \"\" OK\n" ));
467 Debug( LDAP_DEBUG_TRACE,
468 "bdb_modrdn: wr to children of entry \"\" OK\n",
474 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: new superior=\"\", not root & \"\" is not suffix\n" ));
476 Debug( LDAP_DEBUG_TRACE,
477 "bdb_modrdn: new superior=\"\", not root "
478 "& \"\" is not suffix\n",
481 rc = LDAP_INSUFFICIENT_ACCESS;
487 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "bdb_modrdn: new superior=\"\"\n" ));
489 Debug( LDAP_DEBUG_TRACE,
490 "bdb_modrdn: new superior=\"\"\n",
496 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "bdb_modrdn: wr to new parent's children OK\n" ));
498 Debug( LDAP_DEBUG_TRACE,
499 "bdb_modrdn: wr to new parent's children OK\n",
503 new_parent_dn = np_dn;
506 /* Build target dn and make sure target entry doesn't exist already. */
507 build_new_dn( &new_dn, new_parent_dn, newrdn );
509 dnNormalize2( NULL, &new_dn, &new_ndn );
512 LDAP_LOG (( "modrdn", LDAP_LEVEL_RESULTS, "bdb_modrdn: new ndn=%s\n", new_ndn.bv_val ));
514 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new ndn=%s\n",
515 new_ndn.bv_val, 0, 0 );
518 rc = bdb_dn2id ( be, ltid, &new_ndn, &id );
520 case DB_LOCK_DEADLOCK:
521 case DB_LOCK_NOTGRANTED:
526 rc = LDAP_ALREADY_EXISTS;
530 text = "internal error";
535 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: new ndn=%s does not exist\n", new_ndn.bv_val ));
537 Debug( LDAP_DEBUG_TRACE,
538 "bdb_modrdn: new ndn=%s does not exist\n",
539 new_ndn.bv_val, 0, 0 );
542 /* Get attribute type and attribute value of our new rdn, we will
543 * need to add that to our new entry
545 if ( ldap_bv2rdn( newrdn, &new_rdn, (char **)&text,
546 LDAP_DN_FORMAT_LDAP ) )
549 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: can't figure out type(s)/values(s) of newrdn\n" ));
551 Debug( LDAP_DEBUG_TRACE,
552 "bdb_modrdn: can't figure out type(s)/values(s) "
553 "of newrdn\n", 0, 0, 0 );
555 rc = LDAP_OPERATIONS_ERROR;
556 text = "unknown type(s) used in RDN";
561 LDAP_LOG (( "modrdn", LDAP_LEVEL_RESULTS, "bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n", new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val ));
563 Debug( LDAP_DEBUG_TRACE,
564 "bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n",
565 new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val, 0 );
568 if ( ldap_bv2rdn( dn, &old_rdn, (char **)&text,
569 LDAP_DN_FORMAT_LDAP ) )
572 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: can't figure out type(s)/values(s) of old_rdn\n" ));
574 Debug( LDAP_DEBUG_TRACE,
575 "bdb_back_modrdn: can't figure out the old_rdn "
576 "type(s)/value(s)\n", 0, 0, 0 );
579 text = "cannot parse RDN from old DN";
584 if ( newSuperior == NULL
585 && charray_strcasecmp( ( const char ** )old_rdn_types,
586 ( const char ** )new_rdn_types ) != 0 ) {
587 /* Not a big deal but we may say something */
589 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: old_rdn_type(s)=%s, new_rdn_type(s)=%s do not match\n", old_rdn_types[ 0 ], new_rdn_types[ 0 ] ));
591 Debug( LDAP_DEBUG_TRACE,
592 "bdb_modrdn: old_rdn_type(s)=%s, new_rdn_type(s)=%s "
594 old_rdn_types[ 0 ], new_rdn_types[ 0 ], 0 );
599 /* Add new attribute values to the entry */
600 for ( a_cnt = 0; new_rdn[0][ a_cnt ]; a_cnt++ ) {
602 AttributeDescription *desc = NULL;
603 Modifications *mod_tmp;
605 rc = slap_bv2ad( &new_rdn[0][ a_cnt ]->la_attr, &desc, &text );
607 if ( rc != LDAP_SUCCESS ) {
609 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: %s: %s (new)\n", text, new_rdn[0][a_cnt]->la_attr.bv_val ));
611 Debug( LDAP_DEBUG_TRACE,
612 "bdb_modrdn: %s: %s (new)\n",
613 text, new_rdn[0][ a_cnt ]->la_attr.bv_val, 0 );
618 /* ACL check of newly added attrs */
619 if ( !access_allowed( be, conn, op, e, desc,
620 &new_rdn[0][ a_cnt ]->la_value, ACL_WRITE, NULL ) ) {
622 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: access to attr \"%s\" (new) not allowed\n", new_rdn[0][a_cnt]->la_attr.bv_val ));
624 Debug( LDAP_DEBUG_TRACE,
625 "bdb_modrdn: access to attr \"%s\" "
626 "(new) not allowed\n",
627 new_rdn[0][ a_cnt ]->la_attr.bv_val, 0, 0 );
629 rc = LDAP_INSUFFICIENT_ACCESS;
633 /* Apply modification */
634 mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
635 + 2 * sizeof( struct berval ) );
636 mod_tmp->sml_desc = desc;
637 mod_tmp->sml_bvalues = ( BerVarray )( mod_tmp + 1 );
638 mod_tmp->sml_bvalues[ 0 ] = new_rdn[0][ a_cnt ]->la_value;
639 mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
640 mod_tmp->sml_op = SLAP_MOD_SOFTADD;
641 mod_tmp->sml_next = mod;
645 /* Remove old rdn value if required */
646 if ( deleteoldrdn ) {
647 /* Get value of old rdn */
648 if ( old_rdn == NULL) {
650 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: can't figure out old RDN values(s) from old RDN\n" ));
652 Debug( LDAP_DEBUG_TRACE,
653 "bdb_modrdn: can't figure out old RDN value(s) "
654 "from old RDN\n", 0, 0, 0 );
657 text = "could not parse value(s) from old RDN";
661 for ( d_cnt = 0; old_rdn[0][ d_cnt ]; d_cnt++ ) {
663 AttributeDescription *desc = NULL;
664 Modifications *mod_tmp;
666 rc = slap_bv2ad( &old_rdn[0][ d_cnt ]->la_attr,
669 if ( rc != LDAP_SUCCESS ) {
671 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: %s: %s (old)\n", text, old_rdn[0][d_cnt]->la_attr.bv_val ));
673 Debug( LDAP_DEBUG_TRACE,
674 "bdb_modrdn: %s: %s (old)\n",
675 text, old_rdn[0][ d_cnt ]->la_attr.bv_val, 0 );
680 /* ACL check of newly added attrs */
681 if ( !access_allowed( be, conn, op, e, desc,
682 &old_rdn[0][d_cnt]->la_value, ACL_WRITE, NULL ) ) {
684 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: access to attr \"%s\" (old) not allowed\n", old_rdn[0][d_cnt]->la_attr.bv_val ));
686 Debug( LDAP_DEBUG_TRACE,
687 "bdb_modrdn: access to attr \"%s\" "
688 "(old) not allowed\n",
689 old_rdn[0][ d_cnt ]->la_attr.bv_val, 0, 0 );
691 rc = LDAP_INSUFFICIENT_ACCESS;
695 /* Apply modification */
696 mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
697 + 2 * sizeof ( struct berval ) );
698 mod_tmp->sml_desc = desc;
699 mod_tmp->sml_bvalues = ( BerVarray )(mod_tmp+1);
700 mod_tmp->sml_bvalues[ 0 ] = old_rdn[0][ d_cnt ]->la_value;
701 mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
702 mod_tmp->sml_op = LDAP_MOD_DELETE;
703 mod_tmp->sml_next = mod;
709 rc = bdb_dn2id_delete( be, ltid, p_ndn.bv_val, e );
712 case DB_LOCK_DEADLOCK:
713 case DB_LOCK_NOTGRANTED:
717 text = "DN index delete fail";
721 (void) bdb_cache_delete_entry(&bdb->bi_cache, e);
723 /* Binary format uses a single contiguous block, cannot
724 * free individual fields. Leave new_dn/new_ndn set so
725 * they can be individually freed later.
728 e->e_nname = new_ndn;
730 new_dn.bv_val = NULL;
731 new_ndn.bv_val = NULL;
734 rc = bdb_dn2id_add( be, ltid, np_ndn, e );
737 case DB_LOCK_DEADLOCK:
738 case DB_LOCK_NOTGRANTED:
742 text = "DN index add failed";
747 rc = bdb_modify_internal( be, conn, op, ltid, &mod[0], e,
748 &text, textbuf, textlen );
750 if( rc != LDAP_SUCCESS ) {
752 case DB_LOCK_DEADLOCK:
753 case DB_LOCK_NOTGRANTED:
760 rc = bdb_id2entry_update( be, ltid, e );
763 case DB_LOCK_DEADLOCK:
764 case DB_LOCK_NOTGRANTED:
768 text = "entry update failed";
773 if(( rc=TXN_ABORT( ltid )) != 0 ) {
774 text = "txn_abort (no-op) failed";
780 char gid[DB_XIDDATASIZE];
782 snprintf( gid, sizeof( gid ), "%s-%08lx-%08lx",
783 bdb_uuid.bv_val, (long) op->o_connid, (long) op->o_opid );
785 if(( rc=TXN_PREPARE( ltid, gid )) != 0 ) {
786 text = "txn_prepare failed";
788 if( bdb_cache_update_entry(&bdb->bi_cache, e) == -1 ) {
789 if(( rc=TXN_ABORT( ltid )) != 0 ) {
790 text ="cache update & txn_abort failed";
793 text = "cache update failed";
797 if(( rc=TXN_COMMIT( ltid, 0 )) != 0 ) {
798 text = "txn_commit failed";
807 op->o_private = NULL;
809 if( rc == LDAP_SUCCESS ) {
811 LDAP_LOG (( "modrdn", LDAP_LEVEL_RESULTS, "bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n", op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn ));
813 Debug(LDAP_DEBUG_TRACE,
814 "bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n",
815 op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn );
818 bdb_cache_entry_commit( e );
822 LDAP_LOG (( "modrdn", LDAP_LEVEL_RESULTS, "bdb_modrdn: %s : %s (%d)\n", text, db_strerror(rc), rc ));
824 Debug( LDAP_DEBUG_TRACE, "bdb_add: %s : %s (%d)\n",
825 text, db_strerror(rc), rc );
831 send_ldap_result( conn, op, rc,
832 NULL, text, NULL, NULL );
834 if( rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
835 ldap_pvt_thread_yield();
836 TXN_CHECKPOINT( bdb->bi_dbenv,
837 bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
841 if( new_dn.bv_val != NULL ) free( new_dn.bv_val );
842 if( new_ndn.bv_val != NULL ) free( new_ndn.bv_val );
844 /* LDAP v2 supporting correct attribute handling. */
845 if( new_rdn != NULL ) ldap_rdnfree( new_rdn );
846 if( old_rdn != NULL ) ldap_rdnfree( old_rdn );
849 for (; mod; mod=tmp ) {
855 /* LDAP v3 Support */
857 /* free new parent and reader lock */
858 bdb_cache_return_entry_r(&bdb->bi_cache, np);
862 /* free parent and reader lock */
863 bdb_cache_return_entry_r(&bdb->bi_cache, p);
868 bdb_cache_return_entry_w( &bdb->bi_cache, e );
873 op->o_private = NULL;