Complete ldap.class.php and fix minor bugs