2 * Copyright (c) 1990 Regents of the University of Michigan.
11 static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
16 #include <ac/socket.h>
17 #include <ac/string.h>
24 * ldap_modrdn2 - initiate an ldap (and X.500) modifyRDN operation. Parameters:
27 * dn DN of the object to modify
28 * newrdn RDN to give the object
29 * deleteoldrdn nonzero means to delete old rdn values from the entry
32 * msgid = ldap_modrdn( ld, dn, newrdn );
35 ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
40 * A modify rdn request looks like this:
41 * ModifyRDNRequest ::= SEQUENCE {
42 * entry DistinguishedName,
43 * newrdn RelativeDistinguishedName,
44 * deleteoldrdn BOOLEAN
48 Debug( LDAP_DEBUG_TRACE, "ldap_modrdn\n", 0, 0, 0 );
50 /* create a message to send */
51 if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
55 if ( ber_printf( ber, "{it{ssb}}", ++ld->ld_msgid, LDAP_REQ_MODRDN, dn,
56 newrdn, deleteoldrdn ) == -1 ) {
57 ld->ld_errno = LDAP_ENCODING_ERROR;
62 /* send the message */
63 return ( ldap_send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber ));
67 ldap_modrdn( LDAP *ld, char *dn, char *newrdn )
69 return( ldap_modrdn2( ld, dn, newrdn, 1 ) );
73 ldap_modrdn2_s( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
78 if ( (msgid = ldap_modrdn2( ld, dn, newrdn, deleteoldrdn )) == -1 )
79 return( ld->ld_errno );
81 if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
82 return( ld->ld_errno );
84 return( ldap_result2error( ld, res, 1 ) );
88 ldap_modrdn_s( LDAP *ld, char *dn, char *newrdn )
90 return( ldap_modrdn2_s( ld, dn, newrdn, 1 ) );