LDAP support

Hi

Inspired by https://github.com/poweradmin/poweradmin/pull/103 I thought I'd have a go at writing my own LDAP patch.

In this version, an extra column is required in the users table.
ALTER TABLE users ADD use_ldap BOOLEAN NOT NULL DEFAULT 0;

Unlike in nido's patch, use of LDAP is configured per user, not globally and the permissions system is still used.

5 new configuration parameters configure the ldap connection. eg
$ldap_uri               = 'ldap://domaincontroller.example.com';
$ldap_basedn            = 'OU=Users,DC=example,DC=com';
$ldap_binddn            = 'GROUP\lookupuser';
$ldap_bindpw            = '4hJfds8i74hDJ';
$ldap_user_attribute    = 'sAMAccountName';

Secure ldap using ldaps should work if the appropriate ldaps uri is used and openldap has the CA certificate configured correctly.  Likewise, it should be possible to specify redundant ldap/AD servers in the uri.

TODO:
Updates to user management interface to set use_ldap flag.  I've only got as far as having the interface display the current setting per user.  Trying to update the setting does nothing.

Refactoring.  Some code from internalAuthenticate() is duplicated in LDAPAuthenticate() and some (eg proper logging) isn't there at all.  But... hopefully this makes it easier to see that this patch doesn't break anything (I hope!) :)

Kind Regards,
Alex