From 1b0961bee51b7d44e23fa1584530b13c0b57bbe9 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 23 Oct 2015 16:29:44 -0700 Subject: [PATCH] GUAC-1115: Do not require config base DN if not storing connections. --- .../guacamole/auth/ldap/ConfigurationService.java | 11 ++++++----- .../auth/ldap/connection/ConnectionService.java | 8 +++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/extensions/guacamole-auth-ldap/src/main/java/org/glyptodon/guacamole/auth/ldap/ConfigurationService.java b/extensions/guacamole-auth-ldap/src/main/java/org/glyptodon/guacamole/auth/ldap/ConfigurationService.java index 3550d8a4f..886e405e4 100644 --- a/extensions/guacamole-auth-ldap/src/main/java/org/glyptodon/guacamole/auth/ldap/ConfigurationService.java +++ b/extensions/guacamole-auth-ldap/src/main/java/org/glyptodon/guacamole/auth/ldap/ConfigurationService.java @@ -117,18 +117,19 @@ public class ConfigurationService { /** * Returns the base DN under which all Guacamole configurations - * (connections) will be stored within the LDAP directory. + * (connections) will be stored within the LDAP directory. If Guacamole + * configurations will not be stored within LDAP, null is returned. * * @return * The base DN under which all Guacamole configurations will be stored - * within the LDAP directory. + * within the LDAP directory, or null if no Guacamole configurations + * will be stored within the LDAP directory. * * @throws GuacamoleException - * If guacamole.properties cannot be parsed, or if the configuration - * base DN property is not specified. + * If guacamole.properties cannot be parsed. */ public String getConfigurationBaseDN() throws GuacamoleException { - return environment.getRequiredProperty( + return environment.getProperty( LDAPGuacamoleProperties.LDAP_CONFIG_BASE_DN ); } diff --git a/extensions/guacamole-auth-ldap/src/main/java/org/glyptodon/guacamole/auth/ldap/connection/ConnectionService.java b/extensions/guacamole-auth-ldap/src/main/java/org/glyptodon/guacamole/auth/ldap/connection/ConnectionService.java index 9a065fda2..199e91d46 100644 --- a/extensions/guacamole-auth-ldap/src/main/java/org/glyptodon/guacamole/auth/ldap/connection/ConnectionService.java +++ b/extensions/guacamole-auth-ldap/src/main/java/org/glyptodon/guacamole/auth/ldap/connection/ConnectionService.java @@ -28,6 +28,7 @@ import com.novell.ldap.LDAPConnection; import com.novell.ldap.LDAPEntry; import com.novell.ldap.LDAPException; import com.novell.ldap.LDAPSearchResults; +import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; @@ -86,6 +87,11 @@ public class ConnectionService { public Map getConnections(LDAPConnection ldapConnection) throws GuacamoleException { + // Do not return any connections if base DN is not specified + String configurationBaseDN = confService.getConfigurationBaseDN(); + if (configurationBaseDN == null) + return Collections.emptyMap(); + try { // Pull the current user DN from the LDAP connection @@ -98,7 +104,7 @@ public class ConnectionService { // Find all Guacamole connections for the given user LDAPSearchResults results = ldapConnection.search( - confService.getConfigurationBaseDN(), + configurationBaseDN, LDAPConnection.SCOPE_SUB, "(&(objectClass=guacConfigGroup)(member=" + escapingService.escapeLDAPSearchFilter(userDN) + "))", null,