Table of Contents | Previous | Next | Index

Netscape Directory SDK 3.0 for C Programmer’s Guide
     Chapter 18 Functions

ldap_modrdn2()

Changes the relative distinguished name (RDN) of an entry in the directory asynchronously.

Note that this is an older function that is included in the LDAP API for backward-compatibility. If you are writing a new LDAP client, use ldap_rename() instead.

Syntax

#include <ldap.h>
int ldap_modrdn2( LDAP *ld, const char *dn, const char *newrdn,
   int deleteoldrdn );

Parameters

This function has the following parameters:

ld

Connection handle, which is a pointer to an LDAP structure containing information about the connection to the LDAP server.

dn

Distinguished name (DN) of the entry to modify.

newrdn

New relative distinguished name (RDN) to assign to the entry.

deleteoldrdn

If this is a non-zero value, the old RDN is not retained as a value in the modified entry. If 0, the old RDN is retained as an attribute in the modified entry.

Returns

Returns the message ID of the ldap_modrdn2() operation. To check the result of this operation, call ldap_result() and ldap_result2error(). For a list of possible result codes, see the result code documentation for the ldap_rename_s() function.

Description

The ldap_modrdn2() function modifies the relative distinguished name (RDN) of an entry in a directory and lets you specify whether or not the old RDN is retained as an attribute of the entry.

A newer version of this function, ldap_rename(), is available in this release of the LDAP API. ldap_modrdn2() (the older version of the function) is included only for backward-compatibility. If you are writing a new LDAP client, use ldap_rename() instead of ldap_modrdn2().

If you want more information on ldap_modrdn2(), refer to the LDAP C SDK 1.0 Programmer's Guide.

Example

The following section of code uses the asynchronous ldap_modrdn2() function to change the RDN of an entry from "uid=bjensen" to "uid=babs". The code removes the existing RDN "bjensen" from the uid attribute of the entry.

#include <ldap.h>
...
LDAP *ld;
LDAPMessage *result;
int msgid, rc;
struct timeval tv;
/* Distinguished name of the entry that you want to rename. */
char *dn = "uid=bjensen, ou=People, o=Airius.com";
/* New relative distinguished name (RDN) of the entry */
char *rdn = "uid=babs";
...
/* Set up the timeout period to wait for the "modify RDN" operation */
tv.tv_sec = tv.tv_usec = 0;
/* Rename the entry */
if ( ( msgid = ldap_modrdn2( ld, dn, rdn, 1 ) ) == -1 ) {
   ldap_perror( ld, "ldap_modrdn2" );
   return( 1 );
}
/* Check to see if the operation has completed */
while ( ( rc = ldap_result( ld, msgid, 0, &tv, &result ) ) == 0 ) {
   ...
   /* do other work while waiting for the operation to complete */
   ...
}
/* Check the result to see if any errors occurred */
ldap_result2error( ld, result, 1 );
ldap_perror( ld, "ldap_modrdn2" );
...

See Also

ldap_rename().


Table of Contents | Previous | Next | Index

Last Updated: 10/01/98 17:06:23