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 #define MODRDNTAG (ldap_compat == 20 ? OLD_LDAP_RES_MODRDN : LDAP_RES_MODRDN)
33 #define MODRDNTAG LDAP_RES_MODRDN
45 struct ds_modifyrdn_arg ma;
46 static CommonArgs common = default_common_args;
48 Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
51 * Parse the modrdn request. It looks like this:
52 * ModifyRDNRequest := SEQUENCE {
53 * entry DistinguishedName,
54 * newrdn RelativeDistinguishedName
58 #if ISODEPACKAGE == IC
60 DAS_ModifyDnArgument_INIT( &ma );
64 if ( ber_scanf( ber, "{aa", &dn, &newrdn ) == LBER_ERROR ) {
65 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
66 send_ldap_msgresult( clientsb, MODRDNTAG, m,
67 LDAP_PROTOCOL_ERROR, NULL, "" );
72 if ( ber_scanf( ber, "b", &deleteoldrdn ) == LBER_ERROR ) {
73 Debug( LDAP_DEBUG_ANY, "found old modrdn\n", 0, 0, 0 );
76 Debug( LDAP_DEBUG_ARGS,
77 "do_modrdn: dn (%s) newrdn (%s) deleteoldrdn (%d)\n", dn, newrdn,
80 ma.mra_object = ldap_str2dn( dn );
82 if ( ma.mra_object == NULLDN ) {
83 Debug( LDAP_DEBUG_ANY, "ldap_str2dn failed\n", 0, 0, 0 );
84 send_ldap_msgresult( clientsb, MODRDNTAG, m,
85 LDAP_INVALID_DN_SYNTAX, NULL, "" );
89 ma.mra_newrdn = ldap_str2rdn( newrdn );
91 if ( ma.mra_newrdn == NULLRDN ) {
92 Debug( LDAP_DEBUG_ANY, "str2rdn failed\n", 0, 0, 0 );
93 send_ldap_msgresult( clientsb, MODRDNTAG, m,
94 LDAP_INVALID_DN_SYNTAX, NULL, "Bad RDN" );
97 ma.deleterdn = (deleteoldrdn ? 1 : 0);
99 ma.mra_common = common; /* struct copy */
101 rc = initiate_dap_operation( OP_MODIFYRDN, m, &ma );
103 dn_free( ma.mra_object );
104 rdn_free( ma.mra_newrdn );
107 send_ldap_msgresult( clientsb, MODRDNTAG, m, rc, NULL, "" );
115 modrdn_result( Sockbuf *sb, struct msg *m )
117 send_ldap_msgresult( sb, MODRDNTAG, m, LDAP_SUCCESS, NULL, "" );