1 /* modrdn.c - ldbm backend modrdn routine */
11 #include "back-ldbm.h"
12 #include "proto-back-ldbm.h"
24 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
26 char *pdn, *newdn, *p;
32 /* get entry with writer lock */
33 if ( (e = dn2entry_w( be, dn, &matched )) == NULL ) {
34 send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" );
35 if ( matched != NULL ) {
41 if ( (pdn = dn_parent( be, dn )) != NULL ) {
42 /* parent + rdn + separator(s) + null */
43 newdn = (char *) ch_malloc( strlen( pdn ) + strlen( newrdn )
45 if ( dn_type( dn ) == DN_X500 ) {
46 strcpy( newdn, newrdn );
47 strcat( newdn, ", " );
50 strcpy( newdn, newrdn );
51 p = strchr( newrdn, '\0' );
53 if ( *p != '.' && *p != '@' ) {
54 if ( (p = strpbrk( dn, ".@" )) != NULL ) {
63 newdn = strdup( newrdn );
65 (void) dn_normalize( newdn );
67 /* get entry with writer lock */
68 if ( (dn2id ( be, newdn ) ) != NOID ) {
71 send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, NULL, NULL );
75 /* check for abandon */
76 pthread_mutex_lock( &op->o_abandonmutex );
77 if ( op->o_abandon ) {
78 pthread_mutex_unlock( &op->o_abandonmutex );
83 pthread_mutex_unlock( &op->o_abandonmutex );
86 if ( dn2id_add( be, newdn, e->e_id ) != 0 ) {
89 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
94 if ( dn2id_delete( be, dn ) != 0 ) {
97 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
101 (void) cache_delete_entry( &li->li_cache, e );
106 * At some point here we need to update the attribute values in
107 * the entry itself that were effected by this RDN change
108 * (respecting the value of the deleteoldrdn parameter).
110 * Since the code to do this has not yet been written, treat this
111 * omission as a (documented) bug.
115 if ( id2entry_add( be, e ) != 0 ) {
117 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
122 /* free entry and writer lock */
123 cache_return_entry_w( &li->li_cache, e );
124 send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
129 /* free entry and writer lock */
130 cache_return_entry_w( &li->li_cache, e );