2 * Copyright (c) 1995 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.
15 #include <sys/types.h>
16 #include <sys/socket.h>
19 extern Backend *select_backend();
21 extern char *default_referral;
29 char *dn, *odn, *newrdn;
33 Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
36 * Parse the modrdn request. It looks like this:
38 * ModifyRDNRequest := SEQUENCE {
39 * entry DistinguishedName,
40 * newrdn RelativeDistinguishedName
44 if ( ber_scanf( op->o_ber, "{aab}", &dn, &newrdn, &deloldrdn )
46 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
47 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
53 Debug( LDAP_DEBUG_ARGS,
54 "do_modrdn: dn (%s) newrdn (%s) deloldrdn (%d)\n", dn, newrdn,
57 Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d MODRDN dn=\"%s\"\n",
58 conn->c_connid, op->o_opid, dn, 0, 0 );
61 * We could be serving multiple database backends. Select the
62 * appropriate one, or send a referral to our "referral server"
63 * if we don't hold it.
66 if ( (be = select_backend( dn )) == NULL ) {
70 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
76 * do the add if 1 && (2 || 3)
77 * 1) there is an add function implemented in this backend;
78 * 2) this backend is master for what it holds;
79 * 3) it's a replica and the dn supplied is the updatedn.
81 if ( be->be_modrdn != NULL ) {
82 /* do the update here */
83 if ( be->be_updatedn == NULL || strcasecmp( be->be_updatedn,
85 if ( (*be->be_modrdn)( be, conn, op, dn, newrdn,
87 replog( be, LDAP_REQ_MODRDN, odn, newrdn,
91 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
95 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
96 "Function not implemented" );