From d0a0be89f2a774e5438fe844d69541fecb5cafc4 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 27 Mar 2016 18:30:02 -0400 Subject: Added more logging for LDAP client --- app/Core/Ldap/Client.php | 33 +++++++++++++++++++++++++++++++++ app/Core/Ldap/Query.php | 6 ++++++ app/Core/Ldap/User.php | 3 +-- 3 files changed, 40 insertions(+), 2 deletions(-) (limited to 'app/Core/Ldap') diff --git a/app/Core/Ldap/Client.php b/app/Core/Ldap/Client.php index 05658190..cee67da5 100644 --- a/app/Core/Ldap/Client.php +++ b/app/Core/Ldap/Client.php @@ -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; + } } diff --git a/app/Core/Ldap/Query.php b/app/Core/Ldap/Query.php index 1779fa61..bea6d5d6 100644 --- a/app/Core/Ldap/Query.php +++ b/app/Core/Ldap/Query.php @@ -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; diff --git a/app/Core/Ldap/User.php b/app/Core/Ldap/User.php index 52283434..d23ec07e 100644 --- a/app/Core/Ldap/User.php +++ b/app/Core/Ldap/User.php @@ -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)); } -- cgit v1.2.3