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>
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}", &ndn, &newrdn, &deloldrdn )
45 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
46 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
50 Debug( LDAP_DEBUG_ARGS,
51 "do_modrdn: dn (%s) newrdn (%s) deloldrdn (%d)\n", ndn, newrdn,
54 dn_normalize_case( ndn );
56 Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d MODRDN dn=\"%s\"\n",
57 conn->c_connid, op->o_opid, ndn, 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( ndn )) == NULL ) {
68 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
73 /* alias suffix if approp */
74 ndn = suffixAlias( ndn, op, be );
77 * do the add if 1 && (2 || 3)
78 * 1) there is an add function implemented in this backend;
79 * 2) this backend is master for what it holds;
80 * 3) it's a replica and the dn supplied is the update_ndn.
82 if ( be->be_modrdn ) {
83 /* do the update here */
84 if ( be->be_update_ndn == NULL ||
85 strcmp( be->be_update_ndn, op->o_ndn ) == 0 )
87 if ( (*be->be_modrdn)( be, conn, op, ndn, newrdn,
89 replog( be, LDAP_REQ_MODRDN, ndn, 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" );