[patch] OpenLDAP defaults in perdition
Patrick Cernko <[email protected]>
| Newsgroups | gmane.mail.perdition.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Perdition Users, I developed a small patch, which makes it possible to delegate the specification of LDAP servers and default search base to OpenLDAP's configuration mechanisms (ldap.conf, .ldaprc, environment variables). The patch was developed by myself. I wanted to avoid to specify the LDAP servers and default search base twice. We have to provide these settings in /etc/ldap/ldap.conf anyway and so I thought, why not use OpenLDAP's auto-configuration in perdition too. I used perdition-1.18 to develop the patch and modified it to make it apply to the latest mercurial version. Unfortunately I cannot check this versions at the moment, but reading the code, I'm very convinced that it will work as expected. Patch is attached. Signed-off-by: Patrick Cernko <[email protected]> So long, -- Patrick Cernko | mailto:[email protected] ______________________________________________ Perdition-users mailing list [email protected] http://lists.vergenet.net/listinfo/perdition-users
perdition-hg2010-08-24_ldapdefaults.diff
(text/x-patch, 2.8 KB)
diff -uprN perdition.orig/perdition/db/ldap/perditiondb_ldap.c perdition/perdition/db/ldap/perditiondb_ldap.c
--- perdition.orig/perdition/db/ldap/perditiondb_ldap.c 2010-08-24 17:08:42.625402000 +0200
+++ perdition/perdition/db/ldap/perditiondb_ldap.c 2010-08-24 17:37:20.758119737 +0200
@@ -385,10 +385,19 @@ static LDAP *perdition_ldap_initialize (
char *uri;
LDAP *connection = NULL;
- uri = perdition_ldap_uri(lud);
- if (uri == NULL) {
- VANESSA_LOGGER_DEBUG("perdition_ldap_uri");
- return NULL;
+ if ((lud->lud_host == NULL) &&
+ (lud->lud_port == LDAP_PORT) &&
+ (strncmp(lud->lud_scheme, "ldap", 5) == 0)) {
+ VANESSA_LOGGER_DEBUG("ldap_initialize with defaults "
+ "(url=NULL)");
+ uri = NULL;
+
+ } else {
+ uri = perdition_ldap_uri(lud);
+ if (uri == NULL) {
+ VANESSA_LOGGER_DEBUG("perdition_ldap_uri");
+ return NULL;
+ }
}
err = ldap_initialize(&connection, uri);
@@ -511,9 +520,17 @@ int dbserver_get2(const char *key_str, c
}
+ if (strncmp(lud->lud_dn, "default", 8) == 0) {
+ VANESSA_LOGGER_DEBUG("using default ldap search base");
+ dn = NULL;
+ } else {
+ VANESSA_LOGGER_DEBUG_UNSAFE("using ldap search base '%s'",
+ lud->lud_dn);
+ dn = lud->lud_dn;
+ }
/* Perform the search */
- err = ldap_search_s(connection, lud->lud_dn, lud->lud_scope,
+ err = ldap_search_s(connection, dn, lud->lud_scope,
lud->lud_filter, lud->lud_attrs, 0, &res);
/* Simon Fraser has observed that when using openldap 2.4.11 on
* Debian Etch (2.1.30) that ldap_search_s() may return
@@ -536,7 +553,7 @@ int dbserver_get2(const char *key_str, c
VANESSA_LOGGER_LOG_UNSAFE(LOG_WARNING,
"multiple entries returned by filter: "
"base: %s; scope: %s; filter: %s",
- lud->lud_dn, lud->lud_scope, lud->lud_filter);
+ dn, lud->lud_scope, lud->lud_filter);
}
/* See what we got back - we only bother with the first entry */
diff -uprN perdition.orig/perdition/perditiondb.5 perdition/perdition/perditiondb.5
--- perdition.orig/perdition/perditiondb.5 2010-08-24 17:08:42.933733000 +0200
+++ perdition/perdition/perditiondb.5 2010-08-24 17:31:02.571141389 +0200
@@ -442,6 +442,18 @@ are only two attributes the port will no
.P
A script, perditiondb_ldap_makedb is provided to initialise LDAP.
.P
+.B OpenLDAP defaults
+.P
+If you leave the host empty and the protocol "ldap", the default host
+configuration for OpenLDAP will be used. To use the default search
+base for OpenLDAP, you have to specify the special string "default" as
+search base, e.g.:
+.P
+ldap:///default?username,mailhost,port?one?(uid=%s)
+.P
+A common way to set defaults for OpenLDAP is /etc/ldap/ldap.conf, see
+ldap.conf(5) for further details and other ways.
+.P
.B x\-bindpw bindname
.P
Perdition can be configured to use use an alternate bind name, and the
smime.p7s
(application/pkcs7-signature, 5.8 KB) - not displayed