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/>.
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
32 #include "ldb_module.h"
33 #include "dsdb/samdb/ldb_modules/util.h"
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
;
43 ldb
= ldb_module_get_ctx(module
);
45 new_base
= ldb_dn_copy(req
, req
->op
.search
.base
);
47 ldb_module_oom(module
);
50 ldb_dn_remove_extended_components(new_base
);
52 ret
= ldb_build_search_req_ex(&down_req
,
59 req
, dsdb_next_callback
,
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
= {
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
);