Added more logging for LDAP client
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Kanboard\Core\Ldap;
|
||||
|
||||
use LogicException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* LDAP Client
|
||||
@@ -20,6 +21,14 @@ class Client
|
||||
*/
|
||||
protected $ldap;
|
||||
|
||||
/**
|
||||
* Logger instance
|
||||
*
|
||||
* @access private
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* Establish LDAP connection
|
||||
*
|
||||
@@ -165,4 +174,28 @@ class Client
|
||||
{
|
||||
return LDAP_PASSWORD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set logger
|
||||
*
|
||||
* @access public
|
||||
* @param LoggerInterface $logger
|
||||
* @return Client
|
||||
*/
|
||||
public function setLogger(LoggerInterface $logger)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get logger
|
||||
*
|
||||
* @access public
|
||||
* @return LoggerInterface
|
||||
*/
|
||||
public function getLogger()
|
||||
{
|
||||
return $this->logger;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ class Query
|
||||
*/
|
||||
public function execute($baseDn, $filter, array $attributes)
|
||||
{
|
||||
if (DEBUG) {
|
||||
$this->client->getLogger()->debug('BaseDN='.$baseDn);
|
||||
$this->client->getLogger()->debug('Filter='.$filter);
|
||||
$this->client->getLogger()->debug('Attributes='.implode(', ', $attributes));
|
||||
}
|
||||
|
||||
$sr = ldap_search($this->client->getConnection(), $baseDn, $filter, $attributes);
|
||||
if ($sr === false) {
|
||||
return $this;
|
||||
|
||||
@@ -44,8 +44,7 @@ class User
|
||||
*/
|
||||
public static function getUser(Client $client, $username)
|
||||
{
|
||||
$className = get_called_class();
|
||||
$self = new $className(new Query($client));
|
||||
$self = new static(new Query($client));
|
||||
return $self->find($self->getLdapUserPattern($username));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user