summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/dsdb/samdb/ldb_modules/show_deleted.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/show_deleted.c b/source4/dsdb/samdb/ldb_modules/show_deleted.c
index 557e36f0bd..11503e6d3b 100644
--- a/source4/dsdb/samdb/ldb_modules/show_deleted.c
+++ b/source4/dsdb/samdb/ldb_modules/show_deleted.c
@@ -40,7 +40,6 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re
struct ldb_control *control;
struct ldb_control **saved_controls;
struct ldb_request *down_req;
- struct ldb_parse_tree *nodeleted_tree;
struct ldb_parse_tree *new_tree = req->op.search.tree;
int ret;
@@ -50,19 +49,33 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re
control = ldb_request_get_control(req, LDB_CONTROL_SHOW_DELETED_OID);
if (! control) {
- nodeleted_tree = talloc_get_type(ldb_module_get_private(module),
- struct ldb_parse_tree);
- if (nodeleted_tree) {
- new_tree = talloc(req, struct ldb_parse_tree);
- if (!new_tree) {
- ldb_oom(ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
- *new_tree = *nodeleted_tree;
- /* Replace dummy part of 'and' with the old, tree,
- without a parse step */
- new_tree->u.list.elements[0] = req->op.search.tree;
+ /* FIXME: we could use a constant tree here once we
+ are sure that no ldb modules modify trees
+ in-situ */
+ new_tree = talloc(req, struct ldb_parse_tree);
+ if (!new_tree) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
}
+ new_tree->operation = LDB_OP_AND;
+ new_tree->u.list.num_elements = 2;
+ new_tree->u.list.elements = talloc_array(new_tree, struct ldb_parse_tree *, 2);
+ if (!new_tree->u.list.elements) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ new_tree->u.list.elements[0] = talloc(new_tree->u.list.elements, struct ldb_parse_tree);
+ new_tree->u.list.elements[0]->operation = LDB_OP_NOT;
+ new_tree->u.list.elements[0]->u.isnot.child =
+ talloc(new_tree->u.list.elements, struct ldb_parse_tree);
+ if (!new_tree->u.list.elements[0]->u.isnot.child) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ new_tree->u.list.elements[0]->u.isnot.child->operation = LDB_OP_EQUALITY;
+ new_tree->u.list.elements[0]->u.isnot.child->u.equality.attr = "isDeleted";
+ new_tree->u.list.elements[0]->u.isnot.child->u.equality.value = data_blob_string_const("TRUE");
+ new_tree->u.list.elements[1] = req->op.search.tree;
}
ret = ldb_build_search_req_ex(&down_req, ldb, req,
@@ -89,20 +102,10 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re
static int show_deleted_init(struct ldb_module *module)
{
struct ldb_context *ldb;
- struct ldb_parse_tree *nodeleted_tree;
int ret;
ldb = ldb_module_get_ctx(module);
- nodeleted_tree = ldb_parse_tree(module, "(&(replace=me)(!(isDeleted=TRUE)))");
- if (!nodeleted_tree) {
- ldb_debug(ldb, LDB_DEBUG_ERROR,
- "show_deleted: Unable to parse isDeleted master expression!\n");
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- ldb_module_set_private(module, nodeleted_tree);
-
ret = ldb_mod_register_control(module, LDB_CONTROL_SHOW_DELETED_OID);
if (ret != LDB_SUCCESS) {
ldb_debug(ldb, LDB_DEBUG_ERROR,