summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb.c56
1 files changed, 25 insertions, 31 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index fa4a64c19d..4fe2088daf 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -47,20 +47,32 @@
struct ldb_context *ldb_connect(const char *url, unsigned int flags,
const char *options[])
{
+ struct ldb_context *ldb_ctx = NULL;
if (strncmp(url, "tdb:", 4) == 0 ||
strchr(url, ':') == NULL) {
- return ltdb_connect(url, flags, options);
+ ldb_ctx = ltdb_connect(url, flags, options);
}
#if HAVE_LDAP
if (strncmp(url, "ldap", 4) == 0) {
- return lldb_connect(url, flags, options);
+ ldb_ctx = lldb_connect(url, flags, options);
}
#endif
- errno = EINVAL;
- return NULL;
+
+ if (!ldb_ctx) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (ldb_load_modules(ldb_ctx, options) != 0) {
+ ldb_close(ldb_ctx);
+ errno = EINVAL;
+ return NULL;
+ }
+
+ return ldb_ctx;
}
/*
@@ -68,8 +80,7 @@ struct ldb_context *ldb_connect(const char *url, unsigned int flags,
*/
int ldb_close(struct ldb_context *ldb)
{
- ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_close");
- return ldb->ops->close(ldb);
+ return ldb->modules->ops->close(ldb->modules);
}
@@ -84,12 +95,7 @@ int ldb_search(struct ldb_context *ldb,
const char *expression,
const char * const *attrs, struct ldb_message ***res)
{
- int ret;
- ret = ldb->ops->search(ldb, base, scope, expression, attrs, res);
-
- ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_search(%s) -> %d records\n",
- expression, ret);
- return ret;
+ return ldb->modules->ops->search(ldb->modules, base, scope, expression, attrs, res);
}
/*
@@ -97,7 +103,7 @@ int ldb_search(struct ldb_context *ldb,
*/
int ldb_search_free(struct ldb_context *ldb, struct ldb_message **msgs)
{
- return ldb->ops->search_free(ldb, msgs);
+ return ldb->modules->ops->search_free(ldb->modules, msgs);
}
@@ -108,10 +114,7 @@ int ldb_search_free(struct ldb_context *ldb, struct ldb_message **msgs)
int ldb_add(struct ldb_context *ldb,
const struct ldb_message *message)
{
- int ret;
- ret = ldb->ops->add_record(ldb, message);
- ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_add(%s) -> %d\n", message->dn, ret);
- return ret;
+ return ldb->modules->ops->add_record(ldb->modules, message);
}
/*
@@ -120,11 +123,7 @@ int ldb_add(struct ldb_context *ldb,
int ldb_modify(struct ldb_context *ldb,
const struct ldb_message *message)
{
- int ret;
- ret = ldb->ops->modify_record(ldb, message);
- ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_modify(%s) -> %d\n",
- message->dn, ret);
- return ret;
+ return ldb->modules->ops->modify_record(ldb->modules, message);
}
@@ -133,10 +132,7 @@ int ldb_modify(struct ldb_context *ldb,
*/
int ldb_delete(struct ldb_context *ldb, const char *dn)
{
- int ret;
- ret = ldb->ops->delete_record(ldb, dn);
- ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_delete(%s) -> %d\n", dn, ret);
- return ret;
+ return ldb->modules->ops->delete_record(ldb->modules, dn);
}
/*
@@ -144,10 +140,7 @@ int ldb_delete(struct ldb_context *ldb, const char *dn)
*/
int ldb_rename(struct ldb_context *ldb, const char *olddn, const char *newdn)
{
- int ret;
- ret = ldb->ops->rename_record(ldb, olddn, newdn);
- ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_rename(%s,%s) -> %d\n", olddn, newdn);
- return ret;
+ return ldb->modules->ops->rename_record(ldb->modules, olddn, newdn);
}
/*
@@ -155,5 +148,6 @@ int ldb_rename(struct ldb_context *ldb, const char *olddn, const char *newdn)
*/
const char *ldb_errstring(struct ldb_context *ldb)
{
- return ldb->ops->errstring(ldb);
+ return ldb->modules->ops->errstring(ldb->modules);
}
+