diff --git a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/ConfigurationService.java b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/ConfigurationService.java index b5e55554e..af67e2be2 100644 --- a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/ConfigurationService.java +++ b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/ConfigurationService.java @@ -20,16 +20,24 @@ package org.apache.guacamole.auth.ldap; import com.google.inject.Inject; +import com.novell.ldap.LDAPSearchConstraints; import java.util.Collections; import java.util.List; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.environment.Environment; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Service for retrieving configuration information regarding the LDAP server. */ public class ConfigurationService { + /** + * Logger for this class. + */ + private final Logger logger = LoggerFactory.getLogger(ConfigurationService.class); + /** * The Guacamole server environment. */ @@ -264,4 +272,30 @@ public class ConfigurationService { } + /** + * Returns a set of LDAPSearchConstraints to apply globally + * to all LDAP searches rather than having various instances + * dispersed throughout the code. Currently contains the + * maximum number of LDAP results to return in a search, as + * well as whether or not aliases should be dereferenced + * during LDAP operations. + * + * @return + * A LDAPSearchConstraints object containing constraints + * to be applied to all LDAP search operations. + * + * @throws GuacamoleException + * If guacamole.properties cannot be parsed. + */ + public LDAPSearchConstraints getLDAPSearchConstraints() throws GuacamoleException { + + LDAPSearchConstraints constraints = new LDAPSearchConstraints(); + + constraints.setMaxResults(getMaxResults()); + constraints.setDereference(getDereferenceAliases()); + + return constraints; + + } + }