summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-10-10 23:25:38 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-10-10 23:25:38 +0200
commitc1884f31ea13618cd3a94a30f9c413d176d1e258 (patch)
tree4c049b69f9f4b44503a0109d579e7893da25c8f7 /source4/dsdb/samdb
parent7f68870bc939e33df958f708ec7f46253fefadd9 (diff)
downloadsamba-c1884f31ea13618cd3a94a30f9c413d176d1e258.tar.gz
samba-c1884f31ea13618cd3a94a30f9c413d176d1e258.tar.bz2
samba-c1884f31ea13618cd3a94a30f9c413d176d1e258.zip
ldb-samba: Add ldb_wrap_add, remove last schema reference from ldb_wrap.
Diffstat (limited to 'source4/dsdb/samdb')
-rw-r--r--source4/dsdb/samdb/samdb.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c
index 8b0c0fec3f..c2a1e9ec80 100644
--- a/source4/dsdb/samdb/samdb.c
+++ b/source4/dsdb/samdb/samdb.c
@@ -128,12 +128,27 @@ struct ldb_context *samdb_connect(TALLOC_CTX *mem_ctx,
{
struct ldb_context *ldb;
struct dsdb_schema *schema;
- ldb = ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx,
- lpcfg_sam_url(lp_ctx), session_info,
- samdb_credentials(ev_ctx, lp_ctx),
- flags);
+ const char *url;
+ struct cli_credentials *credentials;
+ int ret;
- if (!ldb) {
+ url = lpcfg_sam_url(lp_ctx);
+ credentials = samdb_credentials(ev_ctx, lp_ctx);
+
+ ldb = ldb_wrap_find(url, ev_ctx, lp_ctx, session_info, credentials, flags);
+ if (ldb != NULL)
+ return talloc_reference(mem_ctx, ldb);
+
+ ldb = samba_ldb_init(mem_ctx, ev_ctx, lp_ctx, session_info, credentials);
+
+ if (ldb == NULL)
+ return NULL;
+
+ dsdb_set_global_schema(ldb);
+
+ ret = samba_ldb_connect(ldb, lp_ctx, url, flags);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(ldb);
return NULL;
}
@@ -143,6 +158,11 @@ struct ldb_context *samdb_connect(TALLOC_CTX *mem_ctx,
dsdb_make_schema_global(ldb, schema);
}
+ if (!ldb_wrap_add(url, ev_ctx, lp_ctx, session_info, credentials, flags, ldb)) {
+ talloc_free(ldb);
+ return NULL;
+ }
+
return ldb;
}