+ } else if (add_recycled & !ldb_msg_find_ldb_val(res->msgs[i], "isRecycled") && !rcbin_enabled) {
+ /* There is no isRecycled attribute and the recycle-bin
+ * is not enabled so set isRecycled to TRUE.
+ * We used to not set this attribute before
+ * let's set it
+ */
+
+ DEBUG(1, ("Adding isRecycled\n"));
+ struct ldb_message *msg = ldb_msg_new(mem_ctx);
+ if (msg == NULL) {
+ talloc_free(do_dn);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ msg->dn = res->msgs[i]->dn;
+ ret = ldb_msg_add_string(msg, "isRecycled", "TRUE");
+ if (ret != LDB_SUCCESS) {
+ talloc_free(do_dn);
+ return NT_STATUS_NO_MEMORY;
+ }
+ msg->elements[msg->num_elements - 1].flags = LDB_FLAG_MOD_ADD;
+
+ ret = dsdb_modify(s->samdb, msg, DSDB_SEARCH_SHOW_DELETED);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(do_dn);
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }