ldap_rename() instead.
#include <ldap.h>
int ldap_modrdn2( LDAP *ld, const char *dn, const char *newrdn,
int deleteoldrdn );
ld |
Connection handle, which is a pointer to an |
dn | |
newrdn | New relative distinguished name (RDN) to assign to the entry. |
deleteoldrdn |
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.
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.
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" );
...
ldap_rename().
Last Updated: 10/01/98 17:06:23