More robust LDAP reading (suggested by Tuan Nguyen).