3 * Copyright (c) 1990 Regents of the University of Michigan.
6 * Redistribution and use in source and binary forms are permitted
7 * provided that this notice is preserved and that due credit is given
8 * to the University of Michigan at Ann Arbor. The name of the University
9 * may not be used to endorse or promote products derived from this
10 * software without specific prior written permission. This software
11 * is provided ``as is'' without express or implied warranty.
18 #include <ac/socket.h>
20 #include <quipu/commonarg.h>
21 #include <quipu/attrvalue.h>
22 #include <quipu/ds_error.h>
23 #include <quipu/modifyrdn.h>
24 #include <quipu/dap2.h>
25 #include <quipu/dua.h>
32 #define MODRDNTAG (ldap_compat == 20 ? OLD_LDAP_RES_MODRDN : LDAP_RES_MODRDN)
34 #define MODRDNTAG LDAP_RES_MODRDN
46 struct ds_modifyrdn_arg ma;
47 static CommonArgs common = default_common_args;
49 Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
52 * Parse the modrdn request. It looks like this:
53 * ModifyRDNRequest := SEQUENCE {
54 * entry DistinguishedName,
55 * newrdn RelativeDistinguishedName
59 #if ISODEPACKAGE == IC
61 DAS_ModifyDnArgument_INIT( &ma );
65 if ( ber_scanf( ber, "{aa", &dn, &newrdn ) == LBER_ERROR ) {
66 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
67 send_ldap_msgresult( clientsb, MODRDNTAG, m,
68 LDAP_PROTOCOL_ERROR, NULL, "" );
73 if ( ber_scanf( ber, "b", &deleteoldrdn ) == LBER_ERROR ) {
74 Debug( LDAP_DEBUG_ANY, "found old modrdn\n", 0, 0, 0 );
77 Debug( LDAP_DEBUG_ARGS,
78 "do_modrdn: dn (%s) newrdn (%s) deleteoldrdn (%d)\n", dn, newrdn,
81 ma.mra_object = ldap_str2dn( dn );
83 if ( ma.mra_object == NULLDN ) {
84 Debug( LDAP_DEBUG_ANY, "ldap_str2dn failed\n", 0, 0, 0 );
85 send_ldap_msgresult( clientsb, MODRDNTAG, m,
86 LDAP_INVALID_DN_SYNTAX, NULL, "" );
90 ma.mra_newrdn = ldap_str2rdn( newrdn );
92 if ( ma.mra_newrdn == NULLRDN ) {
93 Debug( LDAP_DEBUG_ANY, "str2rdn failed\n", 0, 0, 0 );
94 send_ldap_msgresult( clientsb, MODRDNTAG, m,
95 LDAP_INVALID_DN_SYNTAX, NULL, "Bad RDN" );
98 ma.deleterdn = (deleteoldrdn ? 1 : 0);
100 ma.mra_common = common; /* struct copy */
102 rc = initiate_dap_operation( OP_MODIFYRDN, m, &ma );
104 dn_free( ma.mra_object );
105 rdn_free( ma.mra_newrdn );
108 send_ldap_msgresult( clientsb, MODRDNTAG, m, rc, NULL, "" );
116 modrdn_result( Sockbuf *sb, struct msg *m )
118 send_ldap_msgresult( sb, MODRDNTAG, m, LDAP_SUCCESS, NULL, "" );