-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1999-2003 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
*
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by the Howard Chu for inclusion
+ * in OpenLDAP Software and subsequently enhanced by Pierangelo
+ * Masarati.
+ */
+/* This is an altered version */
+/*
* Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
*
* This work has been developed to fulfill the requirements
struct metaconn *lc;
int rc = 0;
int candidate = -1;
- char *mdn = NULL,
- *mnewSuperior = NULL;
+ struct berval mdn = { 0, NULL },
+ mnewSuperior = { 0, NULL };
+ dncookie dc;
lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE,
&op->o_req_ndn, &candidate );
goto cleanup;
}
+ dc.conn = op->o_conn;
+ dc.rs = rs;
+
if ( op->oq_modrdn.rs_newSup ) {
int nsCandidate, version = LDAP_VERSION3;
ldap_set_option( lc->conns[ nsCandidate ].ld,
LDAP_OPT_PROTOCOL_VERSION, &version );
-
+
/*
* Rewrite the new superior, if defined and required
*/
- switch ( rewrite_session( li->targets[ nsCandidate ]->rwmap.rwm_rw,
- "newSuperiorDn",
- op->oq_modrdn.rs_newSup->bv_val,
- op->o_conn,
- &mnewSuperior ) ) {
- case REWRITE_REGEXEC_OK:
- if ( mnewSuperior == NULL ) {
- mnewSuperior = ( char * )op->oq_modrdn.rs_newSup;
- }
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "[rw] newSuperiorDn: \"%s\" -> \"%s\"\n",
- op->oq_modrdn.rs_newSup, mnewSuperior, 0 );
-#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS, "rw> newSuperiorDn:"
- " \"%s\" -> \"%s\"\n",
- op->oq_modrdn.rs_newSup->bv_val,
- mnewSuperior, 0 );
-#endif /* !NEW_LOGGING */
- break;
-
- case REWRITE_REGEXEC_UNWILLING:
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
- rs->sr_text = "Operation not allowed";
- rc = -1;
- goto cleanup;
-
- case REWRITE_REGEXEC_ERR:
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "Rewrite error";
+ dc.rwmap = &li->targets[ nsCandidate ]->rwmap;
+ dc.ctx = "newSuperiorDN";
+ if ( ldap_back_dn_massage( &dc, op->oq_modrdn.rs_newSup, &mnewSuperior ) ) {
rc = -1;
goto cleanup;
}
/*
* Rewrite the modrdn dn, if required
*/
- switch ( rewrite_session( li->targets[ candidate ]->rwmap.rwm_rw,
- "modrDn", op->o_req_dn.bv_val,
- op->o_conn, &mdn ) ) {
- case REWRITE_REGEXEC_OK:
- if ( mdn == NULL ) {
- mdn = ( char * )op->o_req_dn.bv_val;
- }
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "[rw] modrDn: \"%s\" -> \"%s\"\n",
- op->o_req_dn.bv_val, mdn, 0 );
-#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS, "rw> modrDn: \"%s\" -> \"%s\"\n",
- op->o_req_dn.bv_val, mdn, 0 );
-#endif /* !NEW_LOGGING */
- break;
-
- case REWRITE_REGEXEC_UNWILLING:
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
- rs->sr_text = "Operation not allowed";
- rc = -1;
- goto cleanup;
-
- case REWRITE_REGEXEC_ERR:
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "Rewrite error";
+ dc.rwmap = &li->targets[ candidate ]->rwmap;
+ dc.ctx = "modrDN";
+ if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
rc = -1;
goto cleanup;
}
- ldap_rename2_s( lc->conns[ candidate ].ld, mdn,
+ ldap_rename2_s( lc->conns[ candidate ].ld, mdn.bv_val,
op->oq_modrdn.rs_newrdn.bv_val,
- mnewSuperior, op->oq_modrdn.rs_deleteoldrdn );
+ mnewSuperior.bv_val,
+ op->oq_modrdn.rs_deleteoldrdn );
cleanup:;
- if ( mdn != op->o_req_dn.bv_val ) {
- free( mdn );
+ if ( mdn.bv_val != op->o_req_dn.bv_val ) {
+ free( mdn.bv_val );
}
- if ( mnewSuperior != NULL
- && mnewSuperior != op->oq_modrdn.rs_newSup->bv_val ) {
- free( mnewSuperior );
+ if ( mnewSuperior.bv_val != NULL
+ && mnewSuperior.bv_val != op->oq_modrdn.rs_newSup->bv_val ) {
+ free( mnewSuperior.bv_val );
}
if ( rc == 0 ) {