Warning: this post may contain rants about computers.
LDAP is, in principle, a very shiny thing. Single database of all your users, contacts, etc, meaning you don't have to hack stuff to keep passwd files, etc in sync.
However, there are a few pitfalls.
#1: make sure your database is indexed
I added some more 'index eq' entries to my slapd.conf, including 'index uid eq' and 'index cn eq'. This should help improve search speed (I think), but has a minor drawback - after restarting slapd, it seemed not to like me.
m@z ~ % ldapsearch -x uid=michael uid
m@z ~ %
Yep, that's right, it returned
absolutely nothing.
Turns out that you need to stop slapd and run
slapdindex (tip: it'll probably screw up all the permissions so go
chown openldap:openldap /var/lib/ldap/*). Restarting it then gives joy!
m@z ~ % ldapsearch -x -LLL uid=michael uid
dn: uid=michael,ou=users,dc=michaelh,dc=hopto,dc=org
uid: michael
m@z ~ %
#2: SSL/TLS issues
The Debian slapd package has switched from OpenSSL to GNUTLS (although in what can really only be described as epic failure, some of the stable packages are linked against one, while some are linked against the other -
bug 457182). That's something of an aside, though - I don't know if it's causing the current issues or not (I know that it has been causing
CompSoc some problems, but
someone else will be taking that over soon).
Anyway, the current issue requires a little background. There are two machines - call them a and z. Now, a is running slapd, which listens on localhost:389 (ldap) and localnetworkip:636 (ldaps). Both machines are set to use LDAP for user lookups, etc. They have the same versions of libnss-ldapd, libpam-ldap, ldapscripts, libldap2, libldap-2.4-2. /etc/ldap/ldap.conf on z has:
URI ldaps://a/
and on a:
URI ldaps://a/ ldap://localhost/
Now, here's the fun bit. ldaps connections from z work:
m@z ~ % ldapsearch -x -H ldaps://a/ uid=michael -LLL uid
dn: uid=michael,ou=users,dc=michaelh,dc=hopto,dc=org
uid: michael
m@z ~ %
However, on a they don't:
m@a(172.16.1.15) ~ % ldapsearch -x -H ldaps://a/ uid=michael -LLL uid
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
m@a(172.16.1.15) ~ %
In the log (running slapd with -d 768), I see:
conn=20 fd=26 ACCEPT from IP=172.16.1.1:49298 (IP=172.16.1.1:636)
conn=20 fd=26 TLS established tls_ssf=16 ssf=16
conn=20 fd=26 closed (connection lost)
In fact, it appears that I was missing a key directive:
tls_cacert /etc/ssl/certs/MichaelSecurePlaces.pem
Having just added it to /etc/nss-ldapd.conf, I get a slightly worrying message:
% sudo invoke-rc.d nslcd restart
Restarting nss-ldapd connection daemon: nslcdnslcd: /etc/nss-ldapd.conf:25: option tls_cacertfile is currently untested (please report any successes)
However, for now it seems to work...
Note: this is all running on a Debian lenny/sid system.
This is what happens when
compressedchaos goes away for a week, and I start my holidays early.