Integrating LDAP into Mutt
If Mutt is your favorite email client and you ever wondered how to integrate email address from LDAP, this post shows you how to do this.
Setup
Install lbdb and libnet-ldap-perl:
aptitude install lbdb libnet-ldap-perl
Once you’ve done that, copy the lbdb configuration files into your home directory:
mkdir .lbdb cp /etc/lbdb.rc .lbdb/rc cp /etc/lbdb_ldap.rc .lbdb/ldap.rc
Add your LDAP server to the .lbdb/ldap.rc, e.g.:
%ldap_server_db = (
'christianschenk' => ['localhost',
'cn=users,dc=christianschenk,dc=org',
'givenname sn cn mail', 'givenname cn sn mail o',
'${mail}', '${givenname} ${sn}', '${o}' ]
);
Then add m_ldap to the line saying METHODS in .lbdb/rc and enable your LDAP server by adding it to the LDAP_NICKS like so:
LDAP_NICKS="christianschenk"
You can test your setup with the lbdbq command: simply call it with a string you’re searching for. Once it works for you like expected, add this line to your .muttrc:
set query_command="lbdbq '%s'"
Mutt will use this to send queries to lbdb.
Usage
If Mutt asks you for the email address simply enter some string and hit CTRL+t or TAB: this will auto-complete the address for you. That’s it.
Leave a Reply