Tidy up ldap_search() and auth_pam() a little bit.