krb5-samba: interdomain trust uses different salt principal
[samba.git] / source4 / dsdb / samdb / ldb_modules / simple_dn.c
1 /*
2    ldb database library
3
4    Copyright (C) Andrew Bartlett 2010
5
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.
10
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.
15
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/>.
18 */
19 /*
20  *  Name: ldb
21  *
22  *  Component: ldb dn simplification module
23  *
24  *  Description: Module to strip off extended componenets from search DNs (not accepted by OpenLDAP backends)
25  *
26  *  Author: Andrew Bartlett
27  */
28
29
30
31 #include "includes.h"
32 #include "ldb_module.h"
33 #include "dsdb/samdb/ldb_modules/util.h"
34
35 /* search */
36 static int simple_dn_search(struct ldb_module *module, struct ldb_request *req)
37 {
38         struct ldb_context *ldb;
39         struct ldb_request *down_req;
40         struct ldb_dn *new_base;
41         int ret;
42
43         ldb = ldb_module_get_ctx(module);
44
45         new_base = ldb_dn_copy(req, req->op.search.base);
46         if (!new_base) {
47                 return ldb_module_oom(module);
48         }
49
50         ldb_dn_remove_extended_components(new_base);
51
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);
64         }
65         talloc_steal(down_req, new_base);
66
67         return ldb_next_request(module, down_req);
68 }
69
70 static const struct ldb_module_ops ldb_simple_dn_module_ops = {
71         .name              = "simple_dn",
72         .search = simple_dn_search
73 };
74
75 int ldb_simple_dn_module_init(const char *version)
76 {
77         LDB_MODULE_CHECK_VERSION(version);
78         return ldb_register_module(&ldb_simple_dn_module_ops);
79 }