Up to Contents

Back to Modifying an Entry

Modifying the Name of an Entry

LDAPv3 provides the Modify DN protocol operation that allows general name change access. The ldap_rename() and ldap_rename_s() routines are used to change the name of an entry.

           int ldap_rename(
                   LDAP            *ld,
                   char            *dn,
                   char            *newrdn,
                   char            *newparent,
                   int             deleteoldrdn,
                   LDAPControl     **serverctrls,
                   LDAPControl     **clientctrls,
                   int             *msgidp

           );
           int ldap_rename_s(
                   LDAP            *ld,
                   char            *dn,
                   char            *newrdn,
                   char            *newparent,
                   int             deleteoldrdn,
                   LDAPControl     **serverctrls,
                   LDAPControl     **clientctrls
           );

Parameters are:

ld
The session handle.
dn
The name of the entry whose DN is to be changed.
newrdn
The new RDN to give the entry.
newparent
The new parent, or superior entry. If this parameter is NULL, only the RDN of the entry is changed. The root DN may be specified by passing a zero length string, "". The newparent parameter should always be NULL when using version 2 of the LDAP protocol; otherwise the server's behavior is undefined.
deleteoldrdn
This parameter only has meaning on the rename routines if newrdn is different than the old RDN. It is a boolean value, if non-zero indicating that the old RDN value(s) should be removed, if zero indicating that the old RDN value(s) should be retained as non-distinguished values of the entry.
serverctrls
List of LDAP server controls.
clientctrls
List of client controls.
msgidp
This result parameter will be set to the message id of the request if the ldap_rename() call succeeds.

The ldap_rename() function initiates an asynchronous modify DN operation and returns the constant LDAP_SUCCESS if the request was successfully sent, or another LDAP error code if not. See the section below on error handling for more information about possible errors and how to interpret them. If successful, ldap_rename() places the DN message id of the request in *msgidp. A subsequent call to ldap_result(), described below, can be used to obtain the result of the rename.

The synchronous ldap_rename_s() returns the result of the operation, either the constant LDAP_SUCCESS if the operation was successful, or another LDAP error code if it was not. See the section below on error handling for more information about possible errors and how to interpret them.

The ldap_rename() and ldap_rename_s() functions both support LDAPv3 server controls and client controls.

Up to Contents

Forward to Adding an Entry