Reduce code
Added some sanity checks to avoid loading LDAP if no LDAP module is enabled in PHP (#644)