Merge branch 'master' of https://gitbox.apache.org/repos/asf/directory-server
diff --git a/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java b/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java
index 1dd8773..b58e6c5 100644
--- a/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java
+++ b/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java
@@ -283,9 +283,6 @@
             try
             {
                 ldapConnection.bind( bindDn, Strings.utf8ToString( bindContext.getCredentials() ) );
-
-                // no need to remain bound to delegate host
-                ldapConnection.unBind();
             }
             catch ( LdapException le )
             {
@@ -293,6 +290,16 @@
                 LOG.info( message );
                 throw new LdapAuthenticationException( message );
             }
+            finally
+            {
+                // no need to remain bound to delegate host
+                ldapConnection.unBind();
+
+                if ( IS_DEBUG )
+                {
+                    LOG.debug( "Authenticated successfully {}", bindContext.getDn() );
+                }
+            }
 
             // Create the new principal
             principal = new LdapPrincipal( getDirectoryService().getSchemaManager(), bindDn,