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>
25 * ldap_modrdn2 - initiate an ldap (and X.500) modifyRDN operation. Parameters:
28 * dn DN of the object to modify
29 * newrdn RDN to give the object
30 * deleteoldrdn nonzero means to delete old rdn values from the entry
33 * msgid = ldap_modrdn( ld, dn, newrdn );
36 ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
41 * A modify rdn request looks like this:
42 * ModifyRDNRequest ::= SEQUENCE {
43 * entry DistinguishedName,
44 * newrdn RelativeDistinguishedName,
45 * deleteoldrdn BOOLEAN
49 Debug( LDAP_DEBUG_TRACE, "ldap_modrdn\n", 0, 0, 0 );
51 /* create a message to send */
52 if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
56 if ( ber_printf( ber, "{it{ssb}}", ++ld->ld_msgid, LDAP_REQ_MODRDN, dn,
57 newrdn, deleteoldrdn ) == -1 ) {
58 ld->ld_errno = LDAP_ENCODING_ERROR;
63 /* send the message */
64 return ( ldap_send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber ));
68 ldap_modrdn( LDAP *ld, char *dn, char *newrdn )
70 return( ldap_modrdn2( ld, dn, newrdn, 1 ) );
74 ldap_modrdn2_s( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
79 if ( (msgid = ldap_modrdn2( ld, dn, newrdn, deleteoldrdn )) == -1 )
80 return( ld->ld_errno );
82 if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
83 return( ld->ld_errno );
85 return( ldap_result2error( ld, res, 1 ) );
89 ldap_modrdn_s( LDAP *ld, char *dn, char *newrdn )
91 return( ldap_modrdn2_s( ld, dn, newrdn, 1 ) );