summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common/ldb.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb/common/ldb.c')
-rw-r--r--source4/lib/ldb/common/ldb.c147
1 files changed, 0 insertions, 147 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index cac0a383d8..ce4796dee2 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -68,153 +68,6 @@ struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx)
return ldb;
}
-static struct backends_list_entry {
- struct ldb_backend_ops *ops;
- struct backends_list_entry *prev, *next;
-} *ldb_backends = NULL;
-
-#ifndef STATIC_LIBLDB_BACKENDS
-
-#ifdef HAVE_LDB_LDAP
-#define LDAP_INIT &ldb_ldap_backend_ops, \
- &ldb_ldapi_backend_ops, \
- &ldb_ldaps_backend_ops,
-#else
-#define LDAP_INIT
-#endif
-
-#ifdef HAVE_LDB_SQLITE3
-#define SQLITE3_INIT &ldb_sqlite3_backend_ops,
-#else
-#define SQLITE3_INIT
-#endif
-
-#define STATIC_LIBLDB_BACKENDS \
- LDAP_INIT \
- SQLITE3_INIT \
- &ldb_tdb_backend_ops, \
- NULL
-#endif
-
-const static struct ldb_backend_ops *builtin_backends[] = {
- STATIC_LIBLDB_BACKENDS
-};
-
-static ldb_connect_fn ldb_find_backend(const char *url)
-{
- struct backends_list_entry *backend;
- int i;
-
- for (i = 0; builtin_backends[i]; i++) {
- if (strncmp(builtin_backends[i]->name, url,
- strlen(builtin_backends[i]->name)) == 0)
- return builtin_backends[i]->connect_fn;
- }
-
- for (backend = ldb_backends; backend; backend = backend->next) {
- if (strncmp(backend->ops->name, url,
- strlen(backend->ops->name)) == 0) {
- return backend->ops->connect_fn;
- }
- }
-
- return NULL;
-}
-
-/*
- register a new ldb backend
-*/
-int ldb_register_backend(const char *url_prefix, ldb_connect_fn connectfn)
-{
- struct ldb_backend_ops *backend;
- struct backends_list_entry *entry;
-
- backend = talloc(talloc_autofree_context(), struct ldb_backend_ops);
- if (!backend) return LDB_ERR_OPERATIONS_ERROR;
-
- entry = talloc(talloc_autofree_context(), struct backends_list_entry);
- if (!entry) {
- talloc_free(backend);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (ldb_find_backend(url_prefix)) {
- return LDB_SUCCESS;
- }
-
- /* Maybe check for duplicity here later on? */
-
- backend->name = talloc_strdup(backend, url_prefix);
- backend->connect_fn = connectfn;
- entry->ops = backend;
- DLIST_ADD(ldb_backends, entry);
-
- return LDB_SUCCESS;
-}
-
-/*
- Return the ldb module form of a database.
- The URL can either be one of the following forms
- ldb://path
- ldapi://path
-
- flags is made up of LDB_FLG_*
-
- the options are passed uninterpreted to the backend, and are
- backend specific.
-
- This allows modules to get at only the backend module, for example where a
- module may wish to direct certain requests at a particular backend.
-*/
-int ldb_connect_backend(struct ldb_context *ldb,
- const char *url,
- const char *options[],
- struct ldb_module **backend_module)
-{
- int ret;
- char *backend;
- ldb_connect_fn fn;
-
- if (strchr(url, ':') != NULL) {
- backend = talloc_strndup(ldb, url, strchr(url, ':')-url);
- } else {
- /* Default to tdb */
- backend = talloc_strdup(ldb, "tdb");
- }
-
- fn = ldb_find_backend(backend);
-
- if (fn == NULL) {
- struct ldb_backend_ops *ops;
- char *symbol_name = talloc_asprintf(ldb, "ldb_%s_backend_ops", backend);
- if (symbol_name == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- ops = ldb_dso_load_symbol(ldb, backend, symbol_name);
- if (ops != NULL) {
- fn = ops->connect_fn;
- }
- talloc_free(symbol_name);
- }
-
- talloc_free(backend);
-
- if (fn == NULL) {
- ldb_debug(ldb, LDB_DEBUG_FATAL,
- "Unable to find backend for '%s'\n", url);
- return LDB_ERR_OTHER;
- }
-
- ret = fn(ldb, url, ldb->flags, options, backend_module);
-
- if (ret != LDB_SUCCESS) {
- ldb_debug(ldb, LDB_DEBUG_ERROR,
- "Failed to connect to '%s'\n", url);
- return ret;
- }
- return ret;
-}
-
/*
try to autodetect a basedn if none specified. This fixes one of my
pet hates about ldapsearch, which is that you have to get a long,