s4:dsdb/subtree_delete: do the recursive delete AS_SYSTEM/TRUSTED (bug #7711)
[Samba/gebeck_regimport.git] / source4 / dsdb / samdb / ldb_modules / simple_dn.c
blobc7b800fec2a6147e0ab695c3b95689987078b5ba
1 /*
2 ldb database library
4 Copyright (C) Andrew Bartlett 2010
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Name: ldb
22 * Component: ldb dn simplification module
24 * Description: Module to strip off extended componenets from search DNs (not accepted by OpenLDAP backends)
26 * Author: Andrew Bartlett
31 #include "includes.h"
32 #include "ldb_module.h"
33 #include "dsdb/samdb/ldb_modules/util.h"
35 /* search */
36 static int simple_dn_search(struct ldb_module *module, struct ldb_request *req)
38 struct ldb_context *ldb;
39 struct ldb_request *down_req;
40 struct ldb_dn *new_base;
41 int ret;
43 ldb = ldb_module_get_ctx(module);
45 new_base = ldb_dn_copy(req, req->op.search.base);
46 if (!new_base) {
47 ldb_module_oom(module);
50 ldb_dn_remove_extended_components(new_base);
52 ret = ldb_build_search_req_ex(&down_req,
53 ldb, req,
54 new_base,
55 req->op.search.scope,
56 req->op.search.tree,
57 req->op.search.attrs,
58 req->controls,
59 req, dsdb_next_callback,
60 req);
61 LDB_REQ_SET_LOCATION(down_req);
62 if (ret != LDB_SUCCESS) {
63 return ldb_operr(ldb);
65 talloc_steal(down_req, new_base);
67 return ldb_next_request(module, down_req);
70 static const struct ldb_module_ops ldb_simple_dn_module_ops = {
71 .name = "simple_dn",
72 .search = simple_dn_search
75 int ldb_simple_dn_module_init(const char *version)
77 LDB_MODULE_CHECK_VERSION(version);
78 return ldb_register_module(&ldb_simple_dn_module_ops);