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 <sys/types.h>
18 #include <sys/socket.h>
21 extern Backend *select_backend();
23 extern char *default_referral;
31 char *dn, *odn, *newrdn;
35 Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
38 * Parse the modrdn request. It looks like this:
40 * ModifyRDNRequest := SEQUENCE {
41 * entry DistinguishedName,
42 * newrdn RelativeDistinguishedName
46 if ( ber_scanf( op->o_ber, "{aab}", &dn, &newrdn, &deloldrdn )
48 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
49 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
55 Debug( LDAP_DEBUG_ARGS,
56 "do_modrdn: dn (%s) newrdn (%s) deloldrdn (%d)\n", dn, newrdn,
59 Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d MODRDN dn=\"%s\"\n",
60 conn->c_connid, op->o_opid, dn, 0, 0 );
63 * We could be serving multiple database backends. Select the
64 * appropriate one, or send a referral to our "referral server"
65 * if we don't hold it.
68 if ( (be = select_backend( dn )) == NULL ) {
72 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
78 * do the add if 1 && (2 || 3)
79 * 1) there is an add function implemented in this backend;
80 * 2) this backend is master for what it holds;
81 * 3) it's a replica and the dn supplied is the updatedn.
83 if ( be->be_modrdn != NULL ) {
84 /* do the update here */
85 if ( be->be_updatedn == NULL || strcasecmp( be->be_updatedn,
87 if ( (*be->be_modrdn)( be, conn, op, dn, newrdn,
89 replog( be, LDAP_REQ_MODRDN, odn, newrdn,
93 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
97 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
98 "Function not implemented" );