From e476fce952daa686ac788333b5989770abe085e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Somogyi=20L=C3=A1szl=C3=B3?= <slaci1@gmail.com>
Date: Tue, 19 Mar 2019 18:39:29 +0100
Subject: [PATCH] #155 fix exception handling for ZendDriver

---
 Driver/ZendLdapDriver.php | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Driver/ZendLdapDriver.php b/Driver/ZendLdapDriver.php
index 576f392..a5e3f17 100644
--- a/Driver/ZendLdapDriver.php
+++ b/Driver/ZendLdapDriver.php
@@ -2,12 +2,12 @@
 
 namespace FR3D\LdapBundle\Driver;
 
+use FR3D\LdapBundle\Exception\SanitizingException;
 use FR3D\LdapBundle\Model\LdapUserInterface;
 use Psr\Log\LoggerInterface;
 use Symfony\Component\Security\Core\User\UserInterface;
 use Zend\Ldap\Exception\LdapException as ZendLdapException;
 use Zend\Ldap\Ldap;
-use FR3D\LdapBundle\Exception\SanitizingException;
 
 /**
  * This class adapt ldap calls to Zend Framework Ldap library functions.
@@ -94,10 +94,11 @@ public function bind(UserInterface $user, $password)
      * Treat a Zend Ldap Exception.
      *
      * @param ZendLdapException $exception
+     * @param string $password
      */
-    protected function zendExceptionHandler(ZendLdapException $exception, $password)
+    protected function zendExceptionHandler(ZendLdapException $exception, $password = null)
     {
-        $sanitizedException = new SanitizingException($exception, $password);
+        $sanitizedException = null !== $password ? new SanitizingException($exception, $password) : $exception;
 
         switch ($exception->getCode()) {
             // Error level codes