summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-06-20 04:56:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:18:35 -0500
commitbd7a474b1967423711ff93c0080ce0f89270e3f9 (patch)
treeb78606ca4efbf1f298fbb3ae525ed5dd2c0a205d /source4
parent6b4f3e17f0e62499e630b8822c807d692b424c23 (diff)
downloadsamba-bd7a474b1967423711ff93c0080ce0f89270e3f9.tar.gz
samba-bd7a474b1967423711ff93c0080ce0f89270e3f9.tar.bz2
samba-bd7a474b1967423711ff93c0080ce0f89270e3f9.zip
r7776: add a method for getting arbitrary opaque data into a ldb context, for use by backends.
Currently only EventContext is used in this way. (This used to be commit 9fa21b245843371f7777682ee4e5b98e2925b4d0)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/common/ldb.c31
-rw-r--r--source4/lib/ldb/include/ldb.h4
-rw-r--r--source4/lib/ldb/include/ldb_private.h7
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c5
4 files changed, 45 insertions, 2 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 450fa75d8e..e268a8d0d7 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -178,3 +178,34 @@ const char *ldb_errstring(struct ldb_context *ldb)
return ldb->modules->ops->errstring(ldb->modules);
}
+
+/*
+ set backend specific opaque parameters
+*/
+int ldb_set_opaque(struct ldb_context *ldb, const char *name, void *value)
+{
+ struct ldb_opaque *o = talloc(ldb, struct ldb_opaque);
+ if (o == NULL) {
+ ldb_oom(ldb);
+ return -1;
+ }
+ o->next = ldb->opaque;
+ o->name = name;
+ o->value = value;
+ ldb->opaque = o;
+ return 0;
+}
+
+/*
+ get a previously set opaque value
+*/
+void *ldb_get_opaque(struct ldb_context *ldb, const char *name)
+{
+ struct ldb_opaque *o;
+ for (o=ldb->opaque;o;o=o->next) {
+ if (strcmp(o->name, name) == 0) {
+ return o->value;
+ }
+ }
+ return NULL;
+}
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index e980633a62..9a3186b41c 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -372,4 +372,8 @@ int ldb_set_debug(struct ldb_context *ldb,
/* this sets up debug to print messages on stderr */
int ldb_set_debug_stderr(struct ldb_context *ldb);
+/* control backend specific opaque values */
+int ldb_set_opaque(struct ldb_context *ldb, const char *name, void *value);
+void *ldb_get_opaque(struct ldb_context *ldb, const char *name);
+
#endif
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index 92588e13fd..8f91b0d9b1 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -77,6 +77,13 @@ struct ldb_context {
/* debugging operations */
struct ldb_debug_ops debug_ops;
+
+ /* backend specific opaque parameters */
+ struct ldb_opaque {
+ struct ldb_opaque *next;
+ const char *name;
+ void *value;
+ } *opaque;
};
/* the modules init function */
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index eefe80c919..b51139aa6f 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -398,7 +398,7 @@ int ildb_connect(struct ldb_context *ldb, const char *url,
ildb->rootDSE = NULL;
- ildb->ldap = ldap_new_connection(ildb, NULL);
+ ildb->ldap = ldap_new_connection(ildb, ldb_get_opaque(ldb, "EventContext"));
if (!ildb->ldap) {
ldb_oom(ldb);
goto failed;
@@ -421,7 +421,8 @@ int ildb_connect(struct ldb_context *ldb, const char *url,
ldb->modules->private_data = ildb;
ldb->modules->ops = &ildb_ops;
- if (cmdline_credentials->username_obtained > CRED_GUESSED) {
+ if (cmdline_credentials != NULL &&
+ cmdline_credentials->username_obtained > CRED_GUESSED) {
status = ldap_bind_sasl(ildb->ldap, cmdline_credentials);
if (!NT_STATUS_IS_OK(status)) {
ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to bind - %s\n",