From 791cfeabbb15001926a28b6801802bf9256663dc Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 15 Dec 2018 14:22:54 -0500 Subject: [PATCH] GUACAMOLE-234: Only try LDAP bind if user authenticated with LDAP. --- .../ldap/AuthenticationProviderService.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java index e53b233c5..9004c132b 100644 --- a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java +++ b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java @@ -300,22 +300,25 @@ public class AuthenticationProviderService { // Bind using credentials associated with AuthenticatedUser Credentials credentials = authenticatedUser.getCredentials(); - Dn bindDn = ((LDAPAuthenticatedUser) authenticatedUser).getBindDn(); - LdapNetworkConnection ldapConnection = ldapService.bindAs(bindDn, credentials.getPassword()); + if (authenticatedUser instanceof LDAPAuthenticatedUser) { + Dn bindDn = ((LDAPAuthenticatedUser) authenticatedUser).getBindDn(); + LdapNetworkConnection ldapConnection = ldapService.bindAs(bindDn, credentials.getPassword()); - try { + try { - // Build user context by querying LDAP - LDAPUserContext userContext = userContextProvider.get(); - userContext.init(authenticatedUser, ldapConnection); - return userContext; + // Build user context by querying LDAP + LDAPUserContext userContext = userContextProvider.get(); + userContext.init(authenticatedUser, ldapConnection); + return userContext; + } + + // Always disconnect + finally { + ldapService.disconnect(ldapConnection); + } } - - // Always disconnect - finally { - ldapService.disconnect(ldapConnection); - } + return null; }