2 Unix SMB/CIFS implementation.
3 Samba utility functions
5 Copyright (C) Andrew Tridgell 2009
6 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2009
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "ldb_module.h"
26 search for attrs on one DN, in the modules below
28 int dsdb_module_search_dn(struct ldb_module *module,
30 struct ldb_result **_res,
31 struct ldb_dn *basedn,
32 const char * const *attrs)
35 struct ldb_request *req;
37 struct ldb_result *res;
39 tmp_ctx = talloc_new(mem_ctx);
41 res = talloc_zero(tmp_ctx, struct ldb_result);
43 return LDB_ERR_OPERATIONS_ERROR;
46 ret = ldb_build_search_req(&req, ldb_module_get_ctx(module), tmp_ctx,
53 ldb_search_default_callback,
55 if (ret != LDB_SUCCESS) {
60 ret = ldb_next_request(module, req);
61 if (ret == LDB_SUCCESS) {
62 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
65 if (ret != LDB_SUCCESS) {
70 if (res->count != 1) {
71 /* we may be reading a DB that does not have the 'check base on search' option... */
72 ret = LDB_ERR_NO_SUCH_OBJECT;
74 *_res = talloc_steal(mem_ctx, res);
81 search for attrs in the modules below
83 int dsdb_module_search(struct ldb_module *module,
85 struct ldb_result **_res,
86 struct ldb_dn *basedn, enum ldb_scope scope,
87 const char * const *attrs,
88 const char *expression)
91 struct ldb_request *req;
93 struct ldb_result *res;
95 tmp_ctx = talloc_new(mem_ctx);
97 res = talloc_zero(tmp_ctx, struct ldb_result);
99 return LDB_ERR_OPERATIONS_ERROR;
102 ret = ldb_build_search_req(&req, ldb_module_get_ctx(module), tmp_ctx,
109 ldb_search_default_callback,
111 if (ret != LDB_SUCCESS) {
112 talloc_free(tmp_ctx);
116 ret = ldb_next_request(module, req);
117 if (ret == LDB_SUCCESS) {
118 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
122 if (ret == LDB_SUCCESS) {
123 *_res = talloc_steal(mem_ctx, res);
125 talloc_free(tmp_ctx);