2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 * Copyright (c) 1990 Regents of the University of Michigan.
13 * Support for MODIFYDN REQUEST V3 (newSuperior) by:
15 * Copyright 1999, Juan C. Gomez, All rights reserved.
16 * This software is not subject to any license of Silicon Graphics
17 * Inc. or Purdue University.
19 * Redistribution and use in source and binary forms are permitted
20 * without restriction or fee of any kind as long as this notice
29 #include <ac/socket.h>
30 #include <ac/string.h>
36 * ldap_rename2 - initiate an ldap (and X.500) modifyDN operation. Parameters:
37 * (LDAP V3 MODIFYDN REQUEST)
39 * dn DN of the object to modify
40 * newrdn RDN to give the object
41 * deleteoldrdn nonzero means to delete old rdn values from the entry
42 * newSuperior DN of the new parent if applicable
46 ldap_rename2( LDAP *ld,\
55 * A modify rdn request looks like this:
56 * ModifyRDNRequest ::= SEQUENCE {
57 * entry DistinguishedName,
58 * newrdn RelativeDistinguishedName,
59 * deleteoldrdn BOOLEAN
60 * newSuperior [0] DistinguishedName [v3 only]
64 Debug( LDAP_DEBUG_TRACE, "ldap_rename2\n", 0, 0, 0 );
66 /* create a message to send */
67 if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
71 if( newSuperior != NULL ) {
73 if ( ber_printf( ber, "{it{ssbts}}",\
79 LDAP_TAG_NEWSUPERIOR,\
83 ld->ld_errno = LDAP_ENCODING_ERROR;
89 /* send the message */
90 return ldap_send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber );
94 /* If no newSuperior fall through to ldap_modrdn2() */
96 return ldap_modrdn2( ld, dn, newrdn, deleteoldrdn );
100 }/* int ldap_rename2() */
104 * ldap_modrdn2 - initiate an ldap (and X.500) modifyRDN operation. Parameters:
107 * dn DN of the object to modify
108 * newrdn RDN to give the object
109 * deleteoldrdn nonzero means to delete old rdn values from the entry
112 * msgid = ldap_modrdn( ld, dn, newrdn );
115 ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
120 * A modify rdn request looks like this:
121 * ModifyRDNRequest ::= SEQUENCE {
122 * entry DistinguishedName,
123 * newrdn RelativeDistinguishedName,
124 * deleteoldrdn BOOLEAN
128 Debug( LDAP_DEBUG_TRACE, "ldap_modrdn\n", 0, 0, 0 );
130 /* create a message to send */
131 if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
135 if ( ber_printf( ber, "{it{ssb}}", ++ld->ld_msgid, LDAP_REQ_MODRDN, dn,
136 newrdn, deleteoldrdn ) == -1 ) {
137 ld->ld_errno = LDAP_ENCODING_ERROR;
142 /* send the message */
143 return ( ldap_send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber ));
147 ldap_modrdn( LDAP *ld, char *dn, char *newrdn )
149 return( ldap_modrdn2( ld, dn, newrdn, 1 ) );
153 ldap_rename2_s( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn,\
160 if ( (msgid = ldap_rename2( ld,\
166 return( ld->ld_errno );
168 if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res )\
170 return( ld->ld_errno );
172 return( ldap_result2error( ld, res, 1 ) );
177 ldap_modrdn2_s( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
182 if ( (msgid = ldap_modrdn2( ld, dn, newrdn, deleteoldrdn )) == -1 )
183 return( ld->ld_errno );
185 if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
186 return( ld->ld_errno );
188 return( ldap_result2error( ld, res, 1 ) );
192 ldap_modrdn_s( LDAP *ld, char *dn, char *newrdn )
194 return( ldap_modrdn2_s( ld, dn, newrdn, 1 ) );