summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-10-23 14:23:40 +1100
committerAndrew Tridgell <tridge@samba.org>2009-10-23 14:52:17 +1100
commit05f93c3e8fe2b0f6e520686742c48c78c96605ab (patch)
tree67439eb79368bc4adf889bd18485294f825ab8bc /source4/dsdb
parent98e4393df926b600354ef16eb4eb19b5e11bf5c3 (diff)
downloadsamba-05f93c3e8fe2b0f6e520686742c48c78c96605ab.tar.gz
samba-05f93c3e8fe2b0f6e520686742c48c78c96605ab.tar.bz2
samba-05f93c3e8fe2b0f6e520686742c48c78c96605ab.zip
s4-dsdb: add a static samdb_credentials
Similarly to system_session(), this creates a static samdb_credentials()
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/samdb.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c
index 6034c25650..c56782bb49 100644
--- a/source4/dsdb/samdb/samdb.c
+++ b/source4/dsdb/samdb/samdb.c
@@ -72,11 +72,21 @@ char *samdb_relative_path(struct ldb_context *ldb,
return full_name;
}
-struct cli_credentials *samdb_credentials(TALLOC_CTX *mem_ctx,
- struct tevent_context *event_ctx,
+/*
+ this returns a static set of system credentials. It is static so
+ that we always get the same pointer in ldb_wrap_connect()
+ */
+struct cli_credentials *samdb_credentials(struct tevent_context *event_ctx,
struct loadparm_context *lp_ctx)
{
- struct cli_credentials *cred = cli_credentials_init(mem_ctx);
+ static struct cli_credentials *static_credentials;
+ struct cli_credentials *cred;
+
+ if (static_credentials) {
+ return static_credentials;
+ }
+
+ cred = cli_credentials_init(talloc_autofree_context());
if (!cred) {
return NULL;
}
@@ -90,8 +100,10 @@ struct cli_credentials *samdb_credentials(TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(cli_credentials_set_secrets(cred, event_ctx, lp_ctx, NULL, NULL,
SECRETS_LDAP_FILTER))) {
/* Perfectly OK - if not against an LDAP backend */
+ talloc_free(cred);
return NULL;
}
+ static_credentials = cred;
return cred;
}
@@ -107,8 +119,8 @@ struct ldb_context *samdb_connect(TALLOC_CTX *mem_ctx,
struct ldb_context *ldb;
ldb = ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx,
lp_sam_url(lp_ctx), session_info,
- samdb_credentials(mem_ctx, ev_ctx, lp_ctx),
- 0, NULL);
+ samdb_credentials(ev_ctx, lp_ctx),
+ 0);
if (!ldb) {
return NULL;
}