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.
14 #include <quipu/commonarg.h>
15 #include <quipu/attrvalue.h>
16 #include <quipu/ds_error.h>
17 #include <quipu/modifyrdn.h>
18 #include <quipu/dap2.h>
19 #include <quipu/dua.h>
20 #include <sys/types.h>
21 #include <sys/socket.h>
27 extern int ldap_compat;
28 #define MODRDNTAG (ldap_compat == 20 ? OLD_LDAP_RES_MODRDN : LDAP_RES_MODRDN)
30 #define MODRDNTAG LDAP_RES_MODRDN
42 struct ds_modifyrdn_arg ma;
43 static CommonArgs common = default_common_args;
44 extern DN ldap_str2dn();
45 extern RDN ldap_str2rdn();
47 Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
50 * Parse the modrdn request. It looks like this:
51 * ModifyRDNRequest := SEQUENCE {
52 * entry DistinguishedName,
53 * newrdn RelativeDistinguishedName
57 #if ISODEPACKAGE == IC
59 DAS_ModifyDnArgument_INIT( &ma );
63 if ( ber_scanf( ber, "{aa", &dn, &newrdn ) == LBER_ERROR ) {
64 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
65 send_ldap_msgresult( clientsb, MODRDNTAG, m,
66 LDAP_PROTOCOL_ERROR, NULL, "" );
71 if ( ber_scanf( ber, "b", &deleteoldrdn ) == LBER_ERROR ) {
72 Debug( LDAP_DEBUG_ANY, "found old modrdn\n", 0, 0, 0 );
75 Debug( LDAP_DEBUG_ARGS,
76 "do_modrdn: dn (%s) newrdn (%s) deleteoldrdn (%d)\n", dn, newrdn,
79 ma.mra_object = ldap_str2dn( dn );
81 if ( ma.mra_object == NULLDN ) {
82 Debug( LDAP_DEBUG_ANY, "ldap_str2dn failed\n", 0, 0, 0 );
83 send_ldap_msgresult( clientsb, MODRDNTAG, m,
84 LDAP_INVALID_DN_SYNTAX, NULL, "" );
88 ma.mra_newrdn = ldap_str2rdn( newrdn );
90 if ( ma.mra_newrdn == NULLRDN ) {
91 Debug( LDAP_DEBUG_ANY, "str2rdn failed\n", 0, 0, 0 );
92 send_ldap_msgresult( clientsb, MODRDNTAG, m,
93 LDAP_INVALID_DN_SYNTAX, NULL, "Bad RDN" );
96 ma.deleterdn = (deleteoldrdn ? 1 : 0);
98 ma.mra_common = common; /* struct copy */
100 rc = initiate_dap_operation( OP_MODIFYRDN, m, &ma );
102 dn_free( ma.mra_object );
103 rdn_free( ma.mra_newrdn );
106 send_ldap_msgresult( clientsb, MODRDNTAG, m, rc, NULL, "" );
114 modrdn_result( Sockbuf *sb, struct msg *m )
116 send_ldap_msgresult( sb, MODRDNTAG, m, LDAP_SUCCESS, NULL, "" );