1 /* modrdn.c - ldap backend modrdn function */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1999-2007 The OpenLDAP Foundation.
6 * Portions Copyright 1999-2003 Howard Chu.
7 * Portions Copyright 2000-2003 Pierangelo Masarati.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted only as authorized by the OpenLDAP
14 * A copy of this license is available in the file LICENSE in the
15 * top-level directory of the distribution or, alternatively, at
16 * <http://www.OpenLDAP.org/license.html>.
19 * This work was initially developed by the Howard Chu for inclusion
20 * in OpenLDAP Software and subsequently enhanced by Pierangelo
28 #include <ac/socket.h>
29 #include <ac/string.h>
32 #include "back-ldap.h"
39 ldapinfo_t *li = (ldapinfo_t *)op->o_bd->be_private;
41 ldapconn_t *lc = NULL;
43 LDAPControl **ctrls = NULL;
44 ldap_back_send_t retrying = LDAP_BACK_RETRYING;
45 int rc = LDAP_SUCCESS;
48 if ( !ldap_back_dobind( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
52 if ( op->orr_newSup ) {
54 switch ( li->li_version ) {
59 if ( op->o_protocol == 0 || op->o_protocol == LDAP_VERSION3 ) {
65 /* op->o_protocol cannot be anything but LDAPv3,
66 * otherwise wouldn't be here */
67 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
68 send_ldap_result( op, rs );
72 newSup = op->orr_newSup->bv_val;
77 rc = ldap_back_controls_add( op, rs, lc, &ctrls );
78 if ( rc != LDAP_SUCCESS ) {
79 send_ldap_result( op, rs );
84 rs->sr_err = ldap_rename( lc->lc_ld, op->o_req_dn.bv_val,
85 op->orr_newrdn.bv_val, newSup,
86 op->orr_deleteoldrdn, ctrls, NULL, &msgid );
87 rc = ldap_back_op_result( lc, op, rs, msgid,
88 li->li_timeout[ SLAP_OP_MODRDN ],
89 ( LDAP_BACK_SENDRESULT | retrying ) );
90 if ( rs->sr_err == LDAP_UNAVAILABLE && retrying ) {
91 retrying &= ~LDAP_BACK_RETRYING;
92 if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
93 /* if the identity changed, there might be need to re-authz */
94 (void)ldap_back_controls_free( op, rs, &ctrls );
100 (void)ldap_back_controls_free( op, rs, &ctrls );
103 ldap_back_release_conn( li, lc );