2 * Copyright (c) 1990 Regents of the University of Michigan.
9 static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
19 #if !defined( MACOS ) && !defined( DOS )
20 #include <sys/types.h>
21 #include <sys/socket.h>
29 * ldap_modrdn2 - initiate an ldap (and X.500) modifyRDN operation. Parameters:
32 * dn DN of the object to modify
33 * newrdn RDN to give the object
34 * deleteoldrdn nonzero means to delete old rdn values from the entry
37 * msgid = ldap_modrdn( ld, dn, newrdn );
40 ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
45 * A modify rdn request looks like this:
46 * ModifyRDNRequest ::= SEQUENCE {
47 * entry DistinguishedName,
48 * newrdn RelativeDistinguishedName,
49 * deleteoldrdn BOOLEAN
53 Debug( LDAP_DEBUG_TRACE, "ldap_modrdn\n", 0, 0, 0 );
55 /* create a message to send */
56 if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
60 if ( ber_printf( ber, "{it{ssb}}", ++ld->ld_msgid, LDAP_REQ_MODRDN, dn,
61 newrdn, deleteoldrdn ) == -1 ) {
62 ld->ld_errno = LDAP_ENCODING_ERROR;
67 /* send the message */
68 return ( send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber ));
72 ldap_modrdn( LDAP *ld, char *dn, char *newrdn )
74 return( ldap_modrdn2( ld, dn, newrdn, 1 ) );
78 ldap_modrdn2_s( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
83 if ( (msgid = ldap_modrdn2( ld, dn, newrdn, deleteoldrdn )) == -1 )
84 return( ld->ld_errno );
86 if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
87 return( ld->ld_errno );
89 return( ldap_result2error( ld, res, 1 ) );
93 ldap_modrdn_s( LDAP *ld, char *dn, char *newrdn )
95 return( ldap_modrdn2_s( ld, dn, newrdn, 1 ) );