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>
28 char *dn, *odn, *newrdn;
32 Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
35 * Parse the modrdn request. It looks like this:
37 * ModifyRDNRequest := SEQUENCE {
38 * entry DistinguishedName,
39 * newrdn RelativeDistinguishedName
43 if ( ber_scanf( op->o_ber, "{aab}", &dn, &newrdn, &deloldrdn )
45 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
46 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
49 odn = ch_strdup( dn );
52 Debug( LDAP_DEBUG_ARGS,
53 "do_modrdn: dn (%s) newrdn (%s) deloldrdn (%d)\n", dn, newrdn,
56 Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d MODRDN dn=\"%s\"\n",
57 conn->c_connid, op->o_opid, dn, 0, 0 );
60 * We could be serving multiple database backends. Select the
61 * appropriate one, or send a referral to our "referral server"
62 * if we don't hold it.
65 if ( (be = select_backend( dn )) == NULL ) {
69 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
75 * do the add if 1 && (2 || 3)
76 * 1) there is an add function implemented in this backend;
77 * 2) this backend is master for what it holds;
78 * 3) it's a replica and the dn supplied is the updatedn.
80 if ( be->be_modrdn != NULL ) {
81 /* do the update here */
82 if ( be->be_updatedn == NULL || strcasecmp( be->be_updatedn,
84 if ( (*be->be_modrdn)( be, conn, op, dn, newrdn,
86 replog( be, LDAP_REQ_MODRDN, odn, newrdn,
90 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
94 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
95 "Function not implemented" );