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.
17 #include <ac/socket.h>
18 #include <ac/string.h>
22 extern Backend *select_backend();
24 extern char *default_referral;
32 char *dn, *odn, *newrdn;
36 Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
39 * Parse the modrdn request. It looks like this:
41 * ModifyRDNRequest := SEQUENCE {
42 * entry DistinguishedName,
43 * newrdn RelativeDistinguishedName
47 if ( ber_scanf( op->o_ber, "{aab}", &dn, &newrdn, &deloldrdn )
49 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
50 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
56 Debug( LDAP_DEBUG_ARGS,
57 "do_modrdn: dn (%s) newrdn (%s) deloldrdn (%d)\n", dn, newrdn,
60 Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d MODRDN dn=\"%s\"\n",
61 conn->c_connid, op->o_opid, dn, 0, 0 );
64 * We could be serving multiple database backends. Select the
65 * appropriate one, or send a referral to our "referral server"
66 * if we don't hold it.
69 if ( (be = select_backend( dn )) == NULL ) {
73 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
79 * do the add if 1 && (2 || 3)
80 * 1) there is an add function implemented in this backend;
81 * 2) this backend is master for what it holds;
82 * 3) it's a replica and the dn supplied is the updatedn.
84 if ( be->be_modrdn != NULL ) {
85 /* do the update here */
86 if ( be->be_updatedn == NULL || strcasecmp( be->be_updatedn,
88 if ( (*be->be_modrdn)( be, conn, op, dn, newrdn,
90 replog( be, LDAP_REQ_MODRDN, odn, newrdn,
94 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
98 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
99 "Function not implemented" );