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>
23 * ldap_modrdn2 - initiate an ldap (and X.500) modifyRDN operation. Parameters:
26 * dn DN of the object to modify
27 * newrdn RDN to give the object
28 * deleteoldrdn nonzero means to delete old rdn values from the entry
31 * msgid = ldap_modrdn( ld, dn, newrdn );
34 ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
39 * A modify rdn request looks like this:
40 * ModifyRDNRequest ::= SEQUENCE {
41 * entry DistinguishedName,
42 * newrdn RelativeDistinguishedName,
43 * deleteoldrdn BOOLEAN
47 Debug( LDAP_DEBUG_TRACE, "ldap_modrdn\n", 0, 0, 0 );
49 /* create a message to send */
50 if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
54 if ( ber_printf( ber, "{it{ssb}}", ++ld->ld_msgid, LDAP_REQ_MODRDN, dn,
55 newrdn, deleteoldrdn ) == -1 ) {
56 ld->ld_errno = LDAP_ENCODING_ERROR;
61 /* send the message */
62 return ( ldap_send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber ));
66 ldap_modrdn( LDAP *ld, char *dn, char *newrdn )
68 return( ldap_modrdn2( ld, dn, newrdn, 1 ) );
72 ldap_modrdn2_s( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
77 if ( (msgid = ldap_modrdn2( ld, dn, newrdn, deleteoldrdn )) == -1 )
78 return( ld->ld_errno );
80 if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
81 return( ld->ld_errno );
83 return( ldap_result2error( ld, res, 1 ) );
87 ldap_modrdn_s( LDAP *ld, char *dn, char *newrdn )
89 return( ldap_modrdn2_s( ld, dn, newrdn, 1 ) );