One problem we’ve always had here at NetAdminTools is the management of our various contacts databases. For the most part we use our Palm OS databases. The problem is that it is difficult to synchronize between various Palm OS databases. An even more nasty problem is that it is quite difficult under Linux to synchronize the Palm OS database with email clients. There are applications that are supposed to work with KDE, Evolution, and other email clients, but they don’t really work that well. Now that Mozilla is fairly stable and works with LDAP, we think the best solution is an LDAP server. This article discusses a way to selectively update entries on the LDAP server from a Palm database. All of us simply have a category on our Palm OS database called Ldap. We then run a perl script to create an LDIF file, and load that into our LDAP database. As an added bonus, we are able to view all LDAP entries in our database from a web browser.
This article will dance around quite a few topics. You should be able to adapt these ideas to many different directory solutions, even if you don’t need to solve the same problem. We will install LDAP, update our Perl modules over the network, and hack a little perl. A word of caution: do not do any of this article on a production server. Use a test box.
We are using four pieces for this project: Apache, openldap-2.0.15, pdb2ldif-1.1, and ldap-abook-1.00. Pdb2ldif and ldap-abook both use perl extensively. This is the hardest part to get working. Search around on google, but basically what you want to do is get CPAN.pm running. It should be working with most perl distributions. Once you have it running, you can just type:
perl -MCPAN -e shell cpan shell -- CPAN exploration and modules installation ReadLine support enabled cpan>
You can now query for different packages you might need. To query for packages containing AddressBook, we would enter:
cpan> i /AddressBook/
If we wanted to install a module called AddressBook, we could just enter:
cpan>install AddressBook
and the CPAN module would find the package and dependencies and install them. Sometimes the module can’t be installed because of missing software that can’t be installed via CPAN. For these, try to find the distribution, extract, and then run “perl Makefile.pl && make && make test && make install” to install. It took us quite awhile to get all the associated software installed, particularly because we are running on an LFS installation.
For Apache installation, search NetAdminTools for Apache. We’ve written on that before. For LDAP installation, we got openldap-2.0.15 (or later) from openldap.org, extracted it into /usr/local/src, and ran “./configure, make depend, make, make install”. The only trick is the slapd.conf file. Here is a copy of our slapd.conf file. Make sure you deal with the password. This slapd.conf file has the password set to the default of “secret”, which you probably don’t want.
You can get pdb2ldif here. [Ed. Note: uslinux.net seems to be gone. We put the source for pdb2ldif up here]. We hacked the pdb2ldif program a bit. Here is a diff:
156c156 < --- > my $categories = $pdb->{appinfo}{categories}; 183a184 > my $rcategory = $record->{category}; 185d185 < 188c188 < --- > if ($rcategory eq 6){ 228c228 < my $dn = "mail=$date,dc=$dc"; --- > # my $dn = "mail=$date,dc=$dc"; 232a233 > my $dn = "cn=$cn,ou=abook,dc=$dc"; 253,255d253 < < print "objectclass: person "; < 273a272 > print "objectclass: abookPerson "; 293c292 < --- > }
All we did was add a couple lines to utilize categories, and then look for a category=6, which happens to be our Ldap category. We also tweaked the objectclass and dn so that it would work with ldap-abook.
You can get ldap-apbook here. This is basically just a cgi script that will do lookups and updates on your LDAP database. Here is a copy of our AddressBook.conf file, which most likely you will want to put in /etc.
After you get this all working, make a category called Ldap. You might have to tweak the script if this category doesn’t end up being a 6. To dump a Palm OS database to LDIF format:
./pdb2ldif --pdb=/home/u-1/.jpilot/AddressDB.pdb --dc=signalq > export
Note that we are using jpilot, wich we like a lot. We have tried kpilot, which has always been complete crap through the years, but unfortunately is the choice for KDE, and is the only one that works well with an Address conduit. Gnome-pilot is still way too unstable, and the conduits don’t work well.
To import the export file into your LDAP database:
ldapadd -D "cn=Manager, ou=abook, dc=signalq" -W -f export
We have used the LDAP directory lookup with Mozillal 0.9.5, and it works just fine. The only tricky part is getting the Base DN right:
ou=abook,dc=signalq
Now, we can use any email client with LDAP capability to use a common database to look up email addresses. All of us can add entries easily to the LDAP database from our Palm OS devices. Life is good. A note on Palm OS devices. We happen to be using a Handspring Visor Edge with a USB interface. Works fine with Linux.