2 * Copyright (c) 1990 Regents of the University of Michigan.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of Michigan at Ann Arbor. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
17 #include <ac/socket.h>
19 #include <quipu/commonarg.h>
20 #include <quipu/attrvalue.h>
21 #include <quipu/ds_error.h>
22 #include <quipu/modifyrdn.h>
23 #include <quipu/dap2.h>
24 #include <quipu/dua.h>
31 extern int ldap_compat;
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;
48 extern DN ldap_str2dn();
49 extern RDN ldap_str2rdn();
51 Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
54 * Parse the modrdn request. It looks like this:
55 * ModifyRDNRequest := SEQUENCE {
56 * entry DistinguishedName,
57 * newrdn RelativeDistinguishedName
61 #if ISODEPACKAGE == IC
63 DAS_ModifyDnArgument_INIT( &ma );
67 if ( ber_scanf( ber, "{aa", &dn, &newrdn ) == LBER_ERROR ) {
68 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
69 send_ldap_msgresult( clientsb, MODRDNTAG, m,
70 LDAP_PROTOCOL_ERROR, NULL, "" );
75 if ( ber_scanf( ber, "b", &deleteoldrdn ) == LBER_ERROR ) {
76 Debug( LDAP_DEBUG_ANY, "found old modrdn\n", 0, 0, 0 );
79 Debug( LDAP_DEBUG_ARGS,
80 "do_modrdn: dn (%s) newrdn (%s) deleteoldrdn (%d)\n", dn, newrdn,
83 ma.mra_object = ldap_str2dn( dn );
85 if ( ma.mra_object == NULLDN ) {
86 Debug( LDAP_DEBUG_ANY, "ldap_str2dn failed\n", 0, 0, 0 );
87 send_ldap_msgresult( clientsb, MODRDNTAG, m,
88 LDAP_INVALID_DN_SYNTAX, NULL, "" );
92 ma.mra_newrdn = ldap_str2rdn( newrdn );
94 if ( ma.mra_newrdn == NULLRDN ) {
95 Debug( LDAP_DEBUG_ANY, "str2rdn failed\n", 0, 0, 0 );
96 send_ldap_msgresult( clientsb, MODRDNTAG, m,
97 LDAP_INVALID_DN_SYNTAX, NULL, "Bad RDN" );
100 ma.deleterdn = (deleteoldrdn ? 1 : 0);
102 ma.mra_common = common; /* struct copy */
104 rc = initiate_dap_operation( OP_MODIFYRDN, m, &ma );
106 dn_free( ma.mra_object );
107 rdn_free( ma.mra_newrdn );
110 send_ldap_msgresult( clientsb, MODRDNTAG, m, rc, NULL, "" );
118 modrdn_result( Sockbuf *sb, struct msg *m )
120 send_ldap_msgresult( sb, MODRDNTAG, m, LDAP_SUCCESS, NULL, "" );