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 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'app/Core/Ldap/Client.php') 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; + } } -- cgit v1.2.3 From febbd8cace0770930b08c01a4d07a2efbb959fd2 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 27 Mar 2016 18:44:03 -0400 Subject: Check if LDAP logger is defined --- app/Api/User.php | 1 + app/Core/Ldap/Client.php | 11 +++++++++++ app/Core/Ldap/Query.php | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'app/Core/Ldap/Client.php') diff --git a/app/Api/User.php b/app/Api/User.php index 9b8081d6..6ee935a3 100644 --- a/app/Api/User.php +++ b/app/Api/User.php @@ -87,6 +87,7 @@ class User extends \Kanboard\Core\Base try { $ldap = LdapClient::connect(); + $ldap->setLogger($this->logger); $user = LdapUser::getUser($ldap, $username); if ($user === null) { diff --git a/app/Core/Ldap/Client.php b/app/Core/Ldap/Client.php index cee67da5..867d67fe 100644 --- a/app/Core/Ldap/Client.php +++ b/app/Core/Ldap/Client.php @@ -198,4 +198,15 @@ class Client { return $this->logger; } + + /** + * Test if a logger is defined + * + * @access public + * @return boolean + */ + public function hasLogger() + { + return $this->logger !== null; + } } diff --git a/app/Core/Ldap/Query.php b/app/Core/Ldap/Query.php index bea6d5d6..7c1524ca 100644 --- a/app/Core/Ldap/Query.php +++ b/app/Core/Ldap/Query.php @@ -48,7 +48,7 @@ class Query */ public function execute($baseDn, $filter, array $attributes) { - if (DEBUG) { + if (DEBUG && $this->client->hasLogger()) { $this->client->getLogger()->debug('BaseDN='.$baseDn); $this->client->getLogger()->debug('Filter='.$filter); $this->client->getLogger()->debug('Attributes='.implode(', ', $attributes)); -- cgit v1.2.3