svn commit: samba r7776 - in branches/SAMBA_4_0/source/lib/ldb: common include ldb_ildap

tridge at samba.org tridge at samba.org
Mon Jun 20 04:56:43 GMT 2005


Author: tridge
Date: 2005-06-20 04:56:43 +0000 (Mon, 20 Jun 2005)
New Revision: 7776

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7776

Log:
add a method for getting arbitrary opaque data into a ldb context, for use by backends. 
Currently only EventContext is used in this way.





Modified:
   branches/SAMBA_4_0/source/lib/ldb/common/ldb.c
   branches/SAMBA_4_0/source/lib/ldb/include/ldb.h
   branches/SAMBA_4_0/source/lib/ldb/include/ldb_private.h
   branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb.c	2005-06-20 04:27:50 UTC (rev 7775)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb.c	2005-06-20 04:56:43 UTC (rev 7776)
@@ -178,3 +178,34 @@
 	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;
+}

Modified: branches/SAMBA_4_0/source/lib/ldb/include/ldb.h
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/include/ldb.h	2005-06-20 04:27:50 UTC (rev 7775)
+++ branches/SAMBA_4_0/source/lib/ldb/include/ldb.h	2005-06-20 04:56:43 UTC (rev 7776)
@@ -372,4 +372,8 @@
 /* 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

Modified: branches/SAMBA_4_0/source/lib/ldb/include/ldb_private.h
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/include/ldb_private.h	2005-06-20 04:27:50 UTC (rev 7775)
+++ branches/SAMBA_4_0/source/lib/ldb/include/ldb_private.h	2005-06-20 04:56:43 UTC (rev 7776)
@@ -77,6 +77,13 @@
 
 	/* 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 */

Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c	2005-06-20 04:27:50 UTC (rev 7775)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c	2005-06-20 04:56:43 UTC (rev 7776)
@@ -398,7 +398,7 @@
 
 	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 @@
 	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",



More information about the samba-cvs mailing list