Fixing query order (otherwise you run into app_key exception before anonymous ldap applied).

Signed-off-by: Katharina Drexel <katharina.drexel@bfh.ch>
This commit is contained in:
Katharina Drexel 2022-08-02 14:24:00 +02:00
parent 9d627936e6
commit 8596c54d6a
No known key found for this signature in database
GPG key ID: 5DE32D31BA76AE6D

View file

@ -169,6 +169,7 @@ class Ldap extends Model
{
$ldap_username = Setting::getSettings()->ldap_uname;
if ( $ldap_username ) {
// Lets return some nicer messages for users who donked their app key, and disable LDAP
try {
$ldap_pass = \Crypt::decrypt(Setting::getSettings()->ldap_pword);
@ -176,7 +177,6 @@ class Ldap extends Model
throw new Exception('Your app key has changed! Could not decrypt LDAP password using your current app key, so LDAP authentication has been disabled. Login with a local account, update the LDAP password and re-enable it in Admin > Settings.');
}
if ( $ldap_username ) {
if (! $ldapbind = @ldap_bind($connection, $ldap_username, $ldap_pass)) {
throw new Exception('Could not bind to LDAP: '.ldap_error($connection));
}