GUAC-1115: Do not require config base DN if not storing connections.

This commit is contained in:
Michael Jumper
2015-10-23 16:29:44 -07:00
parent c173929002
commit 1b0961bee5
2 changed files with 13 additions and 6 deletions

View File

@@ -117,18 +117,19 @@ public class ConfigurationService {
/** /**
* Returns the base DN under which all Guacamole configurations * 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 * @return
* The base DN under which all Guacamole configurations will be stored * 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 * @throws GuacamoleException
* If guacamole.properties cannot be parsed, or if the configuration * If guacamole.properties cannot be parsed.
* base DN property is not specified.
*/ */
public String getConfigurationBaseDN() throws GuacamoleException { public String getConfigurationBaseDN() throws GuacamoleException {
return environment.getRequiredProperty( return environment.getProperty(
LDAPGuacamoleProperties.LDAP_CONFIG_BASE_DN LDAPGuacamoleProperties.LDAP_CONFIG_BASE_DN
); );
} }

View File

@@ -28,6 +28,7 @@ import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPEntry; import com.novell.ldap.LDAPEntry;
import com.novell.ldap.LDAPException; import com.novell.ldap.LDAPException;
import com.novell.ldap.LDAPSearchResults; import com.novell.ldap.LDAPSearchResults;
import java.util.Collections;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -86,6 +87,11 @@ public class ConnectionService {
public Map<String, Connection> getConnections(LDAPConnection ldapConnection) public Map<String, Connection> getConnections(LDAPConnection ldapConnection)
throws GuacamoleException { throws GuacamoleException {
// Do not return any connections if base DN is not specified
String configurationBaseDN = confService.getConfigurationBaseDN();
if (configurationBaseDN == null)
return Collections.<String, Connection>emptyMap();
try { try {
// Pull the current user DN from the LDAP connection // Pull the current user DN from the LDAP connection
@@ -98,7 +104,7 @@ public class ConnectionService {
// Find all Guacamole connections for the given user // Find all Guacamole connections for the given user
LDAPSearchResults results = ldapConnection.search( LDAPSearchResults results = ldapConnection.search(
confService.getConfigurationBaseDN(), configurationBaseDN,
LDAPConnection.SCOPE_SUB, LDAPConnection.SCOPE_SUB,
"(&(objectClass=guacConfigGroup)(member=" + escapingService.escapeLDAPSearchFilter(userDN) + "))", "(&(objectClass=guacConfigGroup)(member=" + escapingService.escapeLDAPSearchFilter(userDN) + "))",
null, null,