fix: Prevent accidental anonymous binds (#4784)

* Prevent ldap and Active Directory authentication from allowing anonymous binds

* fix style
This commit is contained in:
jonathon-k
2016-10-13 09:19:36 -06:00
committed by Tony Murray
parent e7bbde6b52
commit ba9672b986
2 changed files with 7 additions and 3 deletions

View File

@@ -20,7 +20,7 @@ function authenticate($username, $password)
ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, $config['auth_ldap_version']);
}
if (ldap_bind($ldap_connection, $config['auth_ldap_prefix'].$username.$config['auth_ldap_suffix'], $password)) {
if ($password && ldap_bind($ldap_connection, $config['auth_ldap_prefix'].$username.$config['auth_ldap_suffix'], $password)) {
if (!$config['auth_ldap_group']) {
return 1;
} else {
@@ -37,6 +37,8 @@ function authenticate($username, $password)
}
}
}
} elseif (!isset($password) || $password == '') {
echo 'A password is required';
} else {
echo ldap_error($ldap_connection);
}