1 /* modrdn.c - ldbm backend modrdn routine */
6 #include <sys/socket.h>
9 #include "proto-back-ldbm.h"
11 extern char *dn_parent();
23 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
25 char *pdn, *newdn, *p;
31 /* get entry with writer lock */
32 if ( (e = dn2entry_w( be, dn, &matched )) == NULL ) {
33 send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" );
34 if ( matched != NULL ) {
40 if ( (pdn = dn_parent( be, dn )) != NULL ) {
41 /* parent + rdn + separator(s) + null */
42 newdn = (char *) ch_malloc( strlen( pdn ) + strlen( newrdn )
44 if ( dn_type( dn ) == DN_X500 ) {
45 strcpy( newdn, newrdn );
46 strcat( newdn, ", " );
49 strcpy( newdn, newrdn );
50 p = strchr( newrdn, '\0' );
52 if ( *p != '.' && *p != '@' ) {
53 if ( (p = strpbrk( dn, ".@" )) != NULL ) {
62 newdn = strdup( newrdn );
64 (void) dn_normalize( newdn );
66 /* get entry with writer lock */
67 if ( (dn2id ( be, newdn ) ) != NOID ) {
70 send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, NULL, NULL );
74 /* check for abandon */
75 pthread_mutex_lock( &op->o_abandonmutex );
76 if ( op->o_abandon ) {
77 pthread_mutex_unlock( &op->o_abandonmutex );
82 pthread_mutex_unlock( &op->o_abandonmutex );
85 if ( dn2id_add( be, newdn, e->e_id ) != 0 ) {
88 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
93 if ( dn2id_delete( be, dn ) != 0 ) {
96 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
100 (void) cache_delete_entry( &li->li_cache, e );
105 * At some point here we need to update the attribute values in
106 * the entry itself that were effected by this RDN change
107 * (respecting the value of the deleteoldrdn parameter).
109 * Since the code to do this has not yet been written, treat this
110 * omission as a (documented) bug.
114 if ( id2entry_add( be, e ) != 0 ) {
116 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
121 /* free entry and writer lock */
122 cache_return_entry_w( &li->li_cache, e );
123 send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
128 /* free entry and writer lock */
129 cache_return_entry_w( &li->li_cache, e );