summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb/ldb_modules
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-11-24 10:16:45 +0100
committerMichael Adam <obnox@samba.org>2012-11-30 17:17:21 +0100
commit7f88ad3efce5bc14de49b3d73a5dcb19499e1342 (patch)
tree9d99a9b769a96b44ce413741e36a51413e70fecf /source4/dsdb/samdb/ldb_modules
parent5dd4555f391d841b276e53e70eedde36f5190cdd (diff)
downloadsamba-7f88ad3efce5bc14de49b3d73a5dcb19499e1342.tar.gz
samba-7f88ad3efce5bc14de49b3d73a5dcb19499e1342.tar.bz2
samba-7f88ad3efce5bc14de49b3d73a5dcb19499e1342.zip
s4:dsdb/subtree_delete: delete from the leafs to the root (bug #7711)
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules')
-rw-r--r--source4/dsdb/samdb/ldb_modules/subtree_delete.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/subtree_delete.c b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
index f041b7e66e..b1f87f77b5 100644
--- a/source4/dsdb/samdb/ldb_modules/subtree_delete.c
+++ b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
@@ -38,6 +38,19 @@
#include "dsdb/common/util.h"
+static int subtree_delete_sort(struct ldb_message **m1,
+ struct ldb_message **m2,
+ void *private_data)
+{
+ struct ldb_dn *dn1 = (*m1)->dn;
+ struct ldb_dn *dn2 = (*m2)->dn;
+
+ /*
+ * This sorts in tree order, children first
+ */
+ return ldb_dn_compare(dn1, dn2);
+}
+
static int subtree_delete(struct ldb_module *module, struct ldb_request *req)
{
static const char * const attrs[] = { NULL };
@@ -80,6 +93,12 @@ static int subtree_delete(struct ldb_module *module, struct ldb_request *req)
}
/*
+ * First we sort the results from the leaf to the root
+ */
+ LDB_TYPESAFE_QSORT(res->msgs, res->count, NULL,
+ subtree_delete_sort);
+
+ /*
* we need to start from the top since other LDB modules could
* enforce constraints (eg "objectclass" and "samldb" do so).
*