4 Copyright (C) Andrew Tridgell 2004
5 Copyright (C) Simo Sorce 2005-2006
7 ** NOTE! The following LGPL license applies to the ldb
8 ** library. This does NOT imply that all of Samba is released
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Lesser General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later version.
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
21 You should have received a copy of the GNU Lesser General Public
22 License along with this library; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 * Component: ldb core API
31 * Description: core API routines interfacing to ldb backends
33 * Author: Andrew Tridgell
37 #include "ldb/include/includes.h"
40 initialise a ldb context
41 The mem_ctx is optional
43 struct ldb_context *ldb_init(void *mem_ctx)
45 struct ldb_context *ldb = talloc_zero(mem_ctx, struct ldb_context);
48 ret = ldb_setup_wellknown_attributes(ldb);
54 ldb_set_utf8_default(ldb);
59 static struct ldb_backend {
61 ldb_connect_fn connect_fn;
62 struct ldb_backend *prev, *next;
63 } *ldb_backends = NULL;
66 static ldb_connect_fn ldb_find_backend(const char *url)
68 struct ldb_backend *backend;
70 for (backend = ldb_backends; backend; backend = backend->next) {
71 if (strncmp(backend->name, url, strlen(backend->name)) == 0) {
72 return backend->connect_fn;
80 register a new ldb backend
82 int ldb_register_backend(const char *url_prefix, ldb_connect_fn connectfn)
84 struct ldb_backend *backend = talloc(talloc_autofree_context(), struct ldb_backend);
86 if (ldb_find_backend(url_prefix)) {
90 /* Maybe check for duplicity here later on? */
92 backend->name = talloc_strdup(backend, url_prefix);
93 backend->connect_fn = connectfn;
94 DLIST_ADD(ldb_backends, backend);
100 Return the ldb module form of a database. The URL can either be one of the following forms
104 flags is made up of LDB_FLG_*
106 the options are passed uninterpreted to the backend, and are
109 This allows modules to get at only the backend module, for example where a module
110 may wish to direct certain requests at a particular backend.
112 int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *options[],
113 struct ldb_module **backend_module)
119 if (strchr(url, ':') != NULL) {
120 backend = talloc_strndup(ldb, url, strchr(url, ':')-url);
123 backend = talloc_strdup(ldb, "tdb");
126 fn = ldb_find_backend(backend);
129 if (ldb_try_load_dso(ldb, backend) == 0) {
130 fn = ldb_find_backend(backend);
134 talloc_free(backend);
137 ldb_debug(ldb, LDB_DEBUG_FATAL, "Unable to find backend for '%s'\n", url);
138 return LDB_ERR_OTHER;
141 ret = fn(ldb, url, ldb->flags, options, backend_module);
143 if (ret != LDB_SUCCESS) {
144 ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to connect to '%s'\n", url);
151 try to autodetect a basedn if none specified. This fixes one of my
152 pet hates about ldapsearch, which is that you have to get a long,
153 complex basedn right to make any use of it.
155 static const struct ldb_dn *ldb_set_default_basedn(struct ldb_context *ldb)
159 static const char *attrs[] = { "defaultNamingContext", NULL };
160 struct ldb_result *res;
161 struct ldb_dn *basedn=NULL;
163 basedn = ldb_get_opaque(ldb, "default_baseDN");
168 tmp_ctx = talloc_new(ldb);
169 ret = ldb_search(ldb, ldb_dn_new(tmp_ctx), LDB_SCOPE_BASE,
170 "(objectClass=*)", attrs, &res);
171 if (ret == LDB_SUCCESS) {
172 if (res->count == 1) {
173 basedn = ldb_msg_find_attr_as_dn(ldb, res->msgs[0], "defaultNamingContext");
174 ldb_set_opaque(ldb, "default_baseDN", basedn);
179 talloc_free(tmp_ctx);
183 const struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb)
185 return ldb_get_opaque(ldb, "default_baseDN");
189 connect to a database. The URL can either be one of the following forms
193 flags is made up of LDB_FLG_*
195 the options are passed uninterpreted to the backend, and are
198 int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[])
204 ret = ldb_connect_backend(ldb, url, options, &ldb->modules);
205 if (ret != LDB_SUCCESS) {
209 if (ldb_load_modules(ldb, options) != LDB_SUCCESS) {
210 ldb_debug(ldb, LDB_DEBUG_FATAL, "Unable to load modules for '%s'\n", url);
211 return LDB_ERR_OTHER;
214 /* TODO: get timeout from options if available there */
215 ldb->default_timeout = 300; /* set default to 5 minutes */
217 /* set the default base dn */
218 ldb_set_default_basedn(ldb);
223 void ldb_set_errstring(struct ldb_context *ldb, const char *err_string)
225 if (ldb->err_string) {
226 talloc_free(ldb->err_string);
228 ldb->err_string = talloc_strdup(ldb, err_string);
231 void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...)
235 if (ldb->err_string) {
236 talloc_free(ldb->err_string);
239 va_start(ap, format);
240 ldb->err_string = talloc_vasprintf(ldb, format, ap);
244 void ldb_reset_err_string(struct ldb_context *ldb)
246 if (ldb->err_string) {
247 talloc_free(ldb->err_string);
248 ldb->err_string = NULL;
252 #define FIRST_OP(ldb, op) do { \
253 module = ldb->modules; \
254 while (module && module->ops->op == NULL) module = module->next; \
255 if (module == NULL) { \
256 ldb_asprintf_errstring(ldb, "unable to find module or backend to handle operation: " #op); \
257 return LDB_ERR_OPERATIONS_ERROR; \
264 static int ldb_transaction_start_internal(struct ldb_context *ldb)
266 struct ldb_module *module;
268 FIRST_OP(ldb, start_transaction);
270 ldb_reset_err_string(ldb);
272 status = module->ops->start_transaction(module);
273 if (status != LDB_SUCCESS) {
274 if (ldb->err_string == NULL) {
275 /* no error string was setup by the backend */
276 ldb_asprintf_errstring(ldb,
277 "ldb transaction start: %s (%d)",
278 ldb_strerror(status),
288 static int ldb_transaction_commit_internal(struct ldb_context *ldb)
290 struct ldb_module *module;
292 FIRST_OP(ldb, end_transaction);
294 ldb_reset_err_string(ldb);
296 status = module->ops->end_transaction(module);
297 if (status != LDB_SUCCESS) {
298 if (ldb->err_string == NULL) {
299 /* no error string was setup by the backend */
300 ldb_asprintf_errstring(ldb,
301 "ldb transaction commit: %s (%d)",
302 ldb_strerror(status),
312 static int ldb_transaction_cancel_internal(struct ldb_context *ldb)
314 struct ldb_module *module;
316 FIRST_OP(ldb, del_transaction);
318 status = module->ops->del_transaction(module);
319 if (status != LDB_SUCCESS) {
320 if (ldb->err_string == NULL) {
321 /* no error string was setup by the backend */
322 ldb_asprintf_errstring(ldb,
323 "ldb transaction cancel: %s (%d)",
324 ldb_strerror(status),
331 int ldb_transaction_start(struct ldb_context *ldb)
333 /* disable autotransactions */
334 ldb->transaction_active++;
336 return ldb_transaction_start_internal(ldb);
339 int ldb_transaction_commit(struct ldb_context *ldb)
341 /* renable autotransactions (when we reach 0) */
342 if (ldb->transaction_active > 0)
343 ldb->transaction_active--;
345 return ldb_transaction_commit_internal(ldb);
348 int ldb_transaction_cancel(struct ldb_context *ldb)
350 /* renable autotransactions (when we reach 0) */
351 if (ldb->transaction_active > 0)
352 ldb->transaction_active--;
354 return ldb_transaction_cancel_internal(ldb);
357 static int ldb_autotransaction_start(struct ldb_context *ldb)
359 /* explicit transaction active, ignore autotransaction request */
360 if (ldb->transaction_active)
363 return ldb_transaction_start_internal(ldb);
366 static int ldb_autotransaction_commit(struct ldb_context *ldb)
368 /* explicit transaction active, ignore autotransaction request */
369 if (ldb->transaction_active)
372 return ldb_transaction_commit_internal(ldb);
375 static int ldb_autotransaction_cancel(struct ldb_context *ldb)
377 /* explicit transaction active, ignore autotransaction request */
378 if (ldb->transaction_active)
381 return ldb_transaction_cancel_internal(ldb);
384 /* autostarts a transacion if none active */
385 static int ldb_autotransaction_request(struct ldb_context *ldb, struct ldb_request *req)
389 ret = ldb_autotransaction_start(ldb);
390 if (ret != LDB_SUCCESS) {
394 ret = ldb_request(ldb, req);
395 if (ret == LDB_SUCCESS) {
396 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
399 if (ret == LDB_SUCCESS) {
400 return ldb_autotransaction_commit(ldb);
402 ldb_autotransaction_cancel(ldb);
404 if (ldb->err_string == NULL) {
405 /* no error string was setup by the backend */
406 ldb_asprintf_errstring(ldb, "%s (%d)", ldb_strerror(ret), ret);
412 int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
418 return handle->module->ops->wait(handle, type);
421 /* set the specified timeout or, if timeout is 0 set the default timeout */
422 /* timeout == -1 means no timeout */
423 int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout)
425 if (req == NULL) return LDB_ERR_OPERATIONS_ERROR;
428 req->timeout = timeout;
430 req->timeout = ldb->default_timeout;
432 req->starttime = time(NULL);
437 /* calculates the new timeout based on the previous starttime and timeout */
438 int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq)
442 if (newreq == NULL) return LDB_ERR_OPERATIONS_ERROR;
447 return ldb_set_timeout(ldb, newreq, 0);
449 if ((now - oldreq->starttime) > oldreq->timeout) {
450 return LDB_ERR_TIME_LIMIT_EXCEEDED;
452 newreq->starttime = oldreq->starttime;
453 newreq->timeout = oldreq->timeout - (now - oldreq->starttime);
460 NOTE: the request must be a talloc context.
461 returns LDB_ERR_* on errors.
463 int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
465 struct ldb_module *module;
468 ldb_reset_err_string(ldb);
470 /* call the first module in the chain */
471 switch (req->operation) {
473 FIRST_OP(ldb, search);
474 ret = module->ops->search(module, req);
478 ret = module->ops->add(module, req);
481 FIRST_OP(ldb, modify);
482 ret = module->ops->modify(module, req);
486 ret = module->ops->del(module, req);
489 FIRST_OP(ldb, rename);
490 ret = module->ops->rename(module, req);
492 case LDB_SEQUENCE_NUMBER:
493 FIRST_OP(ldb, sequence_number);
494 ret = module->ops->sequence_number(module, req);
497 FIRST_OP(ldb, request);
498 ret = module->ops->request(module, req);
506 search the database given a LDAP-like search expression
508 returns an LDB error code
510 Use talloc_free to free the ldb_message returned in 'res', if successful
513 static int ldb_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
515 struct ldb_result *res;
519 ldb_set_errstring(ldb, "NULL Context in callback");
520 return LDB_ERR_OPERATIONS_ERROR;
523 res = *((struct ldb_result **)context);
529 if (ares->type == LDB_REPLY_ENTRY) {
530 res->msgs = talloc_realloc(res, res->msgs, struct ldb_message *, res->count + 2);
535 res->msgs[res->count + 1] = NULL;
537 res->msgs[res->count] = talloc_move(res->msgs, &ares->message);
541 if (ares->type == LDB_REPLY_REFERRAL) {
543 for (n = 0; res->refs[n]; n++) /*noop*/ ;
548 res->refs = talloc_realloc(res, res->refs, char *, n + 2);
553 res->refs[n] = talloc_move(res->refs, &ares->referral);
554 res->refs[n + 1] = NULL;
557 talloc_steal(res, ares->controls);
564 *((struct ldb_result **)context) = NULL;
565 return LDB_ERR_OPERATIONS_ERROR;
568 int ldb_build_search_req(struct ldb_request **ret_req,
569 struct ldb_context *ldb,
571 const struct ldb_dn *base,
572 enum ldb_scope scope,
573 const char *expression,
574 const char * const *attrs,
575 struct ldb_control **controls,
577 ldb_request_callback_t callback)
579 struct ldb_request *req;
583 req = talloc(mem_ctx, struct ldb_request);
585 ldb_set_errstring(ldb, "Out of Memory");
586 return LDB_ERR_OPERATIONS_ERROR;
589 req->operation = LDB_SEARCH;
591 req->op.search.base = ldb_dn_new(req);
593 req->op.search.base = base;
595 req->op.search.scope = scope;
597 req->op.search.tree = ldb_parse_tree(req, expression);
598 if (req->op.search.tree == NULL) {
599 ldb_set_errstring(ldb, "Unable to parse search expression");
601 return LDB_ERR_OPERATIONS_ERROR;
604 req->op.search.attrs = attrs;
605 req->controls = controls;
606 req->context = context;
607 req->callback = callback;
613 int ldb_build_add_req(struct ldb_request **ret_req,
614 struct ldb_context *ldb,
616 struct ldb_message *message,
617 struct ldb_control **controls,
619 ldb_request_callback_t callback)
621 struct ldb_request *req;
625 req = talloc(mem_ctx, struct ldb_request);
627 ldb_set_errstring(ldb, "Out of Memory");
628 return LDB_ERR_OPERATIONS_ERROR;
631 req->operation = LDB_ADD;
632 req->op.add.message = message;
633 req->controls = controls;
634 req->context = context;
635 req->callback = callback;
642 int ldb_build_mod_req(struct ldb_request **ret_req,
643 struct ldb_context *ldb,
645 struct ldb_message *message,
646 struct ldb_control **controls,
648 ldb_request_callback_t callback)
650 struct ldb_request *req;
654 req = talloc(mem_ctx, struct ldb_request);
656 ldb_set_errstring(ldb, "Out of Memory");
657 return LDB_ERR_OPERATIONS_ERROR;
660 req->operation = LDB_MODIFY;
661 req->op.mod.message = message;
662 req->controls = controls;
663 req->context = context;
664 req->callback = callback;
671 int ldb_build_del_req(struct ldb_request **ret_req,
672 struct ldb_context *ldb,
675 struct ldb_control **controls,
677 ldb_request_callback_t callback)
679 struct ldb_request *req;
683 req = talloc(mem_ctx, struct ldb_request);
685 ldb_set_errstring(ldb, "Out of Memory");
686 return LDB_ERR_OPERATIONS_ERROR;
689 req->operation = LDB_DELETE;
691 req->controls = controls;
692 req->context = context;
693 req->callback = callback;
700 int ldb_build_rename_req(struct ldb_request **ret_req,
701 struct ldb_context *ldb,
703 struct ldb_dn *olddn,
704 struct ldb_dn *newdn,
705 struct ldb_control **controls,
707 ldb_request_callback_t callback)
709 struct ldb_request *req;
713 req = talloc(mem_ctx, struct ldb_request);
715 ldb_set_errstring(ldb, "Out of Memory");
716 return LDB_ERR_OPERATIONS_ERROR;
719 req->operation = LDB_RENAME;
720 req->op.rename.olddn = olddn;
721 req->op.rename.newdn = newdn;
722 req->controls = controls;
723 req->context = context;
724 req->callback = callback;
732 note that ldb_search() will automatically replace a NULL 'base' value with the
733 defaultNamingContext from the rootDSE if available.
735 int ldb_search(struct ldb_context *ldb,
736 const struct ldb_dn *base,
737 enum ldb_scope scope,
738 const char *expression,
739 const char * const *attrs,
740 struct ldb_result **res)
742 struct ldb_request *req;
745 *res = talloc_zero(ldb, struct ldb_result);
747 return LDB_ERR_OPERATIONS_ERROR;
750 ret = ldb_build_search_req(&req, ldb, ldb,
751 base?base:ldb_get_default_basedn(ldb),
757 ldb_search_callback);
759 if (ret != LDB_SUCCESS) goto done;
761 ldb_set_timeout(ldb, req, 0); /* use default timeout */
763 ret = ldb_request(ldb, req);
765 if (ret == LDB_SUCCESS) {
766 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
772 if (ret != LDB_SUCCESS) {
781 add a record to the database. Will fail if a record with the given class and key
784 int ldb_add(struct ldb_context *ldb,
785 const struct ldb_message *message)
787 struct ldb_request *req;
790 ret = ldb_msg_sanity_check(ldb, message);
791 if (ret != LDB_SUCCESS) {
795 ret = ldb_build_add_req(&req, ldb, ldb,
801 if (ret != LDB_SUCCESS) return ret;
803 ldb_set_timeout(ldb, req, 0); /* use default timeout */
805 /* do request and autostart a transaction */
806 ret = ldb_autotransaction_request(ldb, req);
813 modify the specified attributes of a record
815 int ldb_modify(struct ldb_context *ldb,
816 const struct ldb_message *message)
818 struct ldb_request *req;
821 ret = ldb_msg_sanity_check(ldb, message);
822 if (ret != LDB_SUCCESS) return ret;
824 ret = ldb_build_mod_req(&req, ldb, ldb,
830 if (ret != LDB_SUCCESS) return ret;
832 ldb_set_timeout(ldb, req, 0); /* use default timeout */
834 /* do request and autostart a transaction */
835 ret = ldb_autotransaction_request(ldb, req);
843 delete a record from the database
845 int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn)
847 struct ldb_request *req;
850 ret = ldb_build_del_req(&req, ldb, ldb,
856 if (ret != LDB_SUCCESS) return ret;
858 ldb_set_timeout(ldb, req, 0); /* use default timeout */
860 /* do request and autostart a transaction */
861 ret = ldb_autotransaction_request(ldb, req);
868 rename a record in the database
870 int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
872 struct ldb_request *req;
875 ret = ldb_build_rename_req(&req, ldb, ldb,
882 if (ret != LDB_SUCCESS) return ret;
884 ldb_set_timeout(ldb, req, 0); /* use default timeout */
886 /* do request and autostart a transaction */
887 ret = ldb_autotransaction_request(ldb, req);
895 return the global sequence number
897 int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, uint64_t *seq_num)
899 struct ldb_request *req;
902 req = talloc(ldb, struct ldb_request);
904 ldb_set_errstring(ldb, "Out of Memory");
905 return LDB_ERR_OPERATIONS_ERROR;
908 req->operation = LDB_SEQUENCE_NUMBER;
909 req->controls = NULL;
911 req->callback = NULL;
912 ldb_set_timeout(ldb, req, 0); /* use default timeout */
914 req->op.seq_num.type = type;
915 /* do request and autostart a transaction */
916 ret = ldb_request(ldb, req);
918 if (ret == LDB_SUCCESS) {
919 *seq_num = req->op.seq_num.seq_num;
929 return extended error information
931 const char *ldb_errstring(struct ldb_context *ldb)
933 if (ldb->err_string) {
934 return ldb->err_string;
941 return a string explaining what a ldb error constant meancs
943 const char *ldb_strerror(int ldb_err)
948 case LDB_ERR_OPERATIONS_ERROR:
949 return "Operations error";
950 case LDB_ERR_PROTOCOL_ERROR:
951 return "Protocol error";
952 case LDB_ERR_TIME_LIMIT_EXCEEDED:
953 return "Time limit exceeded";
954 case LDB_ERR_SIZE_LIMIT_EXCEEDED:
955 return "Size limit exceeded";
956 case LDB_ERR_COMPARE_FALSE:
957 return "Compare false";
958 case LDB_ERR_COMPARE_TRUE:
959 return "Compare true";
960 case LDB_ERR_AUTH_METHOD_NOT_SUPPORTED:
961 return "Auth method not supported";
962 case LDB_ERR_STRONG_AUTH_REQUIRED:
963 return "Strong auth required";
965 case LDB_ERR_REFERRAL:
966 return "Referral error";
967 case LDB_ERR_ADMIN_LIMIT_EXCEEDED:
968 return "Admin limit exceeded";
969 case LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION:
970 return "Unsupported critical extension";
971 case LDB_ERR_CONFIDENTIALITY_REQUIRED:
972 return "Confidentiality required";
973 case LDB_ERR_SASL_BIND_IN_PROGRESS:
974 return "SASL bind in progress";
975 case LDB_ERR_NO_SUCH_ATTRIBUTE:
976 return "No such attribute";
977 case LDB_ERR_UNDEFINED_ATTRIBUTE_TYPE:
978 return "Undefined attribute type";
979 case LDB_ERR_INAPPROPRIATE_MATCHING:
980 return "Inappropriate matching";
981 case LDB_ERR_CONSTRAINT_VIOLATION:
982 return "Constraint violation";
983 case LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS:
984 return "Attribute or value exists";
985 case LDB_ERR_INVALID_ATTRIBUTE_SYNTAX:
986 return "Invalid attribute syntax";
988 case LDB_ERR_NO_SUCH_OBJECT:
989 return "No such object";
990 case LDB_ERR_ALIAS_PROBLEM:
991 return "Alias problem";
992 case LDB_ERR_INVALID_DN_SYNTAX:
993 return "Invalid DN syntax";
995 case LDB_ERR_ALIAS_DEREFERENCING_PROBLEM:
996 return "Alias dereferencing problem";
998 case LDB_ERR_INAPPROPRIATE_AUTHENTICATION:
999 return "Inappropriate authentication";
1000 case LDB_ERR_INVALID_CREDENTIALS:
1001 return "Invalid credentials";
1002 case LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS:
1003 return "insufficient access rights";
1006 case LDB_ERR_UNAVAILABLE:
1007 return "Unavailable";
1008 case LDB_ERR_UNWILLING_TO_PERFORM:
1009 return "Unwilling to perform";
1010 case LDB_ERR_LOOP_DETECT:
1011 return "Loop detect";
1013 case LDB_ERR_NAMING_VIOLATION:
1014 return "Naming violation";
1015 case LDB_ERR_OBJECT_CLASS_VIOLATION:
1016 return "Object class violation";
1017 case LDB_ERR_NOT_ALLOWED_ON_NON_LEAF:
1018 return "Not allowed on non-leaf";
1019 case LDB_ERR_NOT_ALLOWED_ON_RDN:
1020 return "Not allowed on RDN";
1021 case LDB_ERR_ENTRY_ALREADY_EXISTS:
1022 return "Entry already exists";
1023 case LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED:
1024 return "Object class mods prohibited";
1025 /* 70 RESERVED FOR CLDAP */
1026 case LDB_ERR_AFFECTS_MULTIPLE_DSAS:
1027 return "Affects multiple DSAs";
1033 return "Unknown error";
1037 set backend specific opaque parameters
1039 int ldb_set_opaque(struct ldb_context *ldb, const char *name, void *value)
1041 struct ldb_opaque *o;
1043 /* allow updating an existing value */
1044 for (o=ldb->opaque;o;o=o->next) {
1045 if (strcmp(o->name, name) == 0) {
1051 o = talloc(ldb, struct ldb_opaque);
1054 return LDB_ERR_OTHER;
1056 o->next = ldb->opaque;
1064 get a previously set opaque value
1066 void *ldb_get_opaque(struct ldb_context *ldb, const char *name)
1068 struct ldb_opaque *o;
1069 for (o=ldb->opaque;o;o=o->next) {
1070 if (strcmp(o->name, name) == 0) {