Skip to content

A free open source IT asset/license management system

Added sanity check to determine if a bind user account is set. (#9340)

Raell Dottin78cc47a85931
diff --git a/app/Services/LdapAd.php b/app/Services/LdapAd.php
index 01e6f77d59..925927d1fe 100644
--- a/app/Services/LdapAd.php
+++ b/app/Services/LdapAd.php
@@ -129,7 +129,13 @@ class LdapAd extends LdapAdConfiguration
$login_username = $username;
}
- if ($this->ldap->auth()->attempt($login_username, $password, true) === false) {
+ if ($this->ldapConfig['username'] && $this->ldapConfig['password']) {
+ $bind_as_user = false;
+ } else {
+ $bind_as_user = true;
+ }
+
+ if ($this->ldap->auth()->attempt($login_username, $password, $bind_as_user) === false) {
throw new Exception('Unable to validate user credentials!');
}