Merge pull request #11510 from sunflowerbofh/tmp-ldap

Fixed #11509 allow-ldap-anonymous-bind
This commit is contained in:
snipe 2022-08-22 16:32:07 -07:00 committed by GitHub
commit 45f17fea8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -169,6 +169,7 @@ class Ldap extends Model
{ {
$ldap_username = Setting::getSettings()->ldap_uname; $ldap_username = Setting::getSettings()->ldap_uname;
if ( $ldap_username ) {
// Lets return some nicer messages for users who donked their app key, and disable LDAP // Lets return some nicer messages for users who donked their app key, and disable LDAP
try { try {
$ldap_pass = \Crypt::decrypt(Setting::getSettings()->ldap_pword); $ldap_pass = \Crypt::decrypt(Setting::getSettings()->ldap_pword);
@ -184,8 +185,13 @@ class Ldap extends Model
// so I don't want to fix this right now. // so I don't want to fix this right now.
// this method MODIFIES STATE on the passed-in $connection and just returns true or false (or, in this case, undefined) // this method MODIFIES STATE on the passed-in $connection and just returns true or false (or, in this case, undefined)
// at the next refactor, this should be appropriately modified to be more consistent. // at the next refactor, this should be appropriately modified to be more consistent.
} else {
// LDAP should also work with anonymous bind (no dn, no password available)
if (! $ldapbind = @ldap_bind($connection )) {
throw new Exception('Could not bind to LDAP: '.ldap_error($connection));
}
}
} }
/** /**
* Parse and map LDAP attributes based on settings * Parse and map LDAP attributes based on settings