Monday, April 03, 2006

Thunderbird Address Book and LDAP

Here at Oxford University we have an LDAP server that contains details of all the staff and students, although it isn't yet a production service it is available to computing services (OUCS) staff members. At first I tried configuring Thunderbird to access the LDAP server but found that searches took far too long so I just forgot about it and carried on using Thunderbird without LDAP support. Then one of my colleagues Paul Trafford was trying to switch from Eudora to Thunderbird and was complaining that Thunderbird was taking ages to perform searches so I had another look into it. The reason that the searches were taking ages is that it was performing queries on attributes that don't have good indexes and so these required full scans taking a long time. Unfortunately finding and changing the queries used by Thunderbird isn't an easy task. After a little Googling the first thing to come up was a page explaining how LDAP attributes map onto Address Book properties and although this was useful it didn't explain how to change the search that was begin run. A few people have blogged this and someone else's experience with Thunderbird and LDAP was helpful although it didn't go all the way to solving my problems. After a little more Googling I found another page that have details of hidden preferences for LDAP searches. Now using this and the search that Paul had used in Eudora I was able to recreate a useful and fast LDAP search. Here are the lines for pref.js in your Thunderbird profile directory. You should only edit this file when Thunderbird is not running as it gets saved when Thunderbird closes. user_pref("ldap_2.autoComplete.directoryServer", "ldap_2.servers.Oxford"); user_pref("ldap_2.servers.Oxford.description", "Oxford"); user_pref("ldap_2.servers.Oxford.filename", "abook-1.mab"); // Oxford uses an objectClass of oucsOrganizationPerson to show a person. user_pref("ldap_2.servers.Oxford.uri", "ldap://ldap.ox.ac.uk:389/ou=people,dc=ox,dc=ac,dc=uk??sub?(objectClass=oucsOrganizationalPerson)"); // Our LDAP stores some other useful data that should be mapped to attributes so we can search on it. user_pref("ldap_2.servers.default.attrmap.Custom1", "universityBarcode"); user_pref("ldap_2.servers.default.attrmap.Custom2", "oucsUsername"); user_pref("ldap_2.servers.default.attrmap.Custom3", "uniqueIdentifier"); user_pref("ldap_2.servers.default.attrmap.Department", "oucsDivision"); // Although we have a displayname field it isn't indexed so search and diplay common name. user_pref("ldap_2.servers.default.attrmap.DisplayName", "cn"); user_pref("ldap_2.servers.default.attrmap.PreferMailFormat", "preferredMail"); // Search on Oxford stuff user_pref("mail.addr_book.quicksearchquery.format", "?(or(Custom1,=,@V)(Custom2,=,@V)(Custom3,=,@V)(DisplayName,c,@V))"); Adding this to your config means that you can search on the common name, barcode, uniqueID and username and it is fast. It doesn't mean that you will be able to use the LDAP server when composing mails though as it seems that some of these preferences aren't used by that code and so the search still looks at the default attributes and as a result very slow here. This has only been tested with Thunderbird 1.5

No comments: