+ struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
+ struct ltdb_context *ltdb_ac;
+ struct ldb_message *msg;
+ int tret, ret = LDB_SUCCESS;
+
+ if (req->controls != NULL) {
+ ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Controls should not reach the ldb_tdb backend!\n");
+ if (check_critical_controls(req->controls)) {
+ return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
+ }
+ }
+
+ req->handle = NULL;
+
+ if (ltdb_cache_load(module) != 0) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ req->handle = init_ltdb_handle(ltdb, module, req);
+ if (req->handle == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ ltdb_ac = talloc_get_type(req->handle->private_data, struct ltdb_context);
+
+ msg = talloc(ltdb_ac, struct ldb_message);
+ if (msg == NULL) {
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ goto done;
+ }
+
+ /* in case any attribute of the message was indexed, we need
+ to fetch the old record */
+ tret = ltdb_search_dn1(module, req->op.rename.olddn, msg);
+ if (tret != 1) {
+ /* not finding the old record is an error */
+ req->handle->status = LDB_ERR_NO_SUCH_OBJECT;
+ goto done;
+ }
+
+ msg->dn = ldb_dn_copy(msg, req->op.rename.newdn);
+ if (!msg->dn) {
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ goto done;
+ }
+
+ tret = ltdb_add_internal(module, msg);
+ if (tret != LDB_SUCCESS) {
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ goto done;
+ }
+
+ tret = ltdb_delete_internal(module, req->op.rename.olddn);
+ if (tret != LDB_SUCCESS) {
+ ltdb_delete_internal(module, req->op.rename.newdn);
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ goto done;
+ }
+
+ if (ltdb_ac->callback) {
+ ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
+ }
+done:
+ req->handle->state = LDB_ASYNC_DONE;