2 /* modrdn.c - tcl modify rdn routines
4 * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
6 * Redistribution and use in source and binary forms are permitted only
7 * as authorized by the OpenLDAP Public License. A copy of this
8 * license is available at http://www.OpenLDAP.org/license.html or
9 * in file LICENSE in the top-level directory of the distribution.
13 * LDAP v3 newSuperior support.
15 * Copyright 1999, Juan C. Gomez, All rights reserved.
16 * This software is not subject to any license of Silicon Graphics
17 * Inc. or Purdue University.
19 * Redistribution and use in source and binary forms are permitted
20 * without restriction or fee of any kind as long as this notice
38 char *command, *results;
39 struct berval suf_tcl;
41 struct tclinfo *ti = (struct tclinfo *) op->o_bd->be_private;
43 if (ti->ti_modrdn.bv_len == 0) {
44 send_ldap_error (op, rs, LDAP_UNWILLING_TO_PERFORM,
45 "modrdn not implemented" );
49 if (tcl_merge_bvlist (op->o_bd->be_suffix, &suf_tcl) == NULL) {
50 send_ldap_error (op, rs, LDAP_OTHER, NULL);
54 command = (char *) ch_malloc (ti->ti_modrdn.bv_len + suf_tcl.bv_len
55 + op->o_req_dn.bv_len + op->oq_modrdn.rs_newrdn.bv_len
56 + (op->oq_modrdn.rs_newSup ? op->oq_modrdn.rs_newSup->bv_len : 0) + 84);
57 if ( op->oq_modrdn.rs_newSup ) {
58 sprintf (command, "%s MODRDN {%ld/%ld} {%s} {%s} {%s} %d {%s}",
60 op->o_connid, (long) op->o_msgid,
61 suf_tcl.bv_val, op->o_req_dn.bv_val,
62 op->oq_modrdn.rs_newrdn.bv_val, op->oq_modrdn.rs_deleteoldrdn ? 1 : 0,
63 op->oq_modrdn.rs_newSup->bv_val );
65 sprintf (command, "%s MODRDN {%ld} {%s} {%s} {%s} %d",
66 ti->ti_modrdn.bv_val, (long) op->o_msgid,
67 suf_tcl.bv_val, op->o_req_dn.bv_val,
68 op->oq_modrdn.rs_newrdn.bv_val, op->oq_modrdn.rs_deleteoldrdn ? 1 : 0 );
70 Tcl_Free (suf_tcl.bv_val);
72 ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex);
73 code = Tcl_GlobalEval (ti->ti_ii->interp, command);
74 results = (char *) ch_strdup (ti->ti_ii->interp->result);
75 ldap_pvt_thread_mutex_unlock (&tcl_interpreter_mutex);
79 rs->sr_err = LDAP_OTHER;
80 Debug (LDAP_DEBUG_SHELL, "tcl_modrdn_error: %s\n", results,
83 interp_send_results (op, rs, results);
86 if (rs->sr_err != LDAP_SUCCESS) {
87 rs->sr_text = "internal backend error";
88 send_ldap_result (op, rs);