1
0
Fork 0
mirror of https://gitlab.easter-eggs.com/ee/ldapsaisie.git synced 2024-12-25 09:53:48 +01:00

LSauthMethod_basic::authenticate(): add debug/trace messages

This commit is contained in:
Benjamin Renard 2020-08-07 18:27:54 +02:00
parent 5fcf3bbf9c
commit 848d85589b

View file

@ -54,16 +54,19 @@ class LSauthMethod_basic extends LSauthMethod {
$authobjects = LSauth :: username2LSobjects($this -> authData['username']); $authobjects = LSauth :: username2LSobjects($this -> authData['username']);
if (!$authobjects) { if (!$authobjects) {
LSerror :: addErrorCode('LSauth_01'); LSerror :: addErrorCode('LSauth_01');
self :: log_debug('Invalid username'); self :: log_debug('No user found with username="'.$this -> authData['username'].'" => Invalid username');
return false; return false;
} }
self :: log_debug('Username "'.$this -> authData['username'].'" matched with following user(s): "'.implode('", "', array_keys($authobjects)).'"');
$matched = array(); $matched = array();
foreach(array_keys($authobjects) as $dn) foreach(array_keys($authobjects) as $dn)
if ( LSldap :: checkBind($dn, $this -> authData['password']) ) if ( LSldap :: checkBind($dn, $this -> authData['password']) )
$matched[] = $dn; $matched[] = $dn;
else
self :: log_trace("Invalid password provided for '$dn'");
if (!$matched) { if (!$matched) {
LSerror :: addErrorCode('LSauth_01'); LSerror :: addErrorCode('LSauth_01');
self :: log_debug('Invalid password'); self :: log_debug('Invalid password provided');
return false; return false;
} }
elseif (count($matched) > 1) { elseif (count($matched) > 1) {
@ -72,6 +75,7 @@ class LSauthMethod_basic extends LSauthMethod {
return false; return false;
} }
// Authentication succeeded // Authentication succeeded
self :: log_debug('Authentication succeeded for username "'.$this -> authData['username'].'" ("'.$matched[0].'")');
return $authobjects[$matched[0]]; return $authobjects[$matched[0]];
} }