Massive rewrite of the LDAP module.