GUACAMOLE-79: Merge changes allowing LDAP result size limits to be overridden.

This commit is contained in:
Michael Jumper
2016-11-11 09:18:50 -08:00
3 changed files with 35 additions and 1 deletions

View File

@@ -206,4 +206,23 @@ public class ConfigurationService {
);
}
/**
* Returns maximum number of results a LDAP query can return,
* as configured with guacamole.properties.
* By default, this will be 1000.
*
* @return
* The maximum number of results a LDAP query can return,
* as configured with guacamole.properties.
*
* @throws GuacamoleException
* If guacamole.properties cannot be parsed.
*/
public int getMaxResults() throws GuacamoleException {
return environment.getProperty(
LDAPGuacamoleProperties.LDAP_MAX_SEARCH_RESULTS,
1000
);
}
}

View File

@@ -145,4 +145,14 @@ public class LDAPGuacamoleProperties {
};
/**
* The maximum number of results a LDAP query can return.
*/
public static final IntegerGuacamoleProperty LDAP_MAX_SEARCH_RESULTS = new IntegerGuacamoleProperty() {
@Override
public String getName() { return "ldap-max-search-results"; }
};
}

View File

@@ -25,6 +25,7 @@ import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPEntry;
import com.novell.ldap.LDAPException;
import com.novell.ldap.LDAPSearchResults;
import com.novell.ldap.LDAPSearchConstraints;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -86,6 +87,9 @@ public class UserService {
String usernameAttribute) throws GuacamoleException {
try {
// Set search limits
LDAPSearchConstraints constraints = new LDAPSearchConstraints();
constraints.setMaxResults(confService.getMaxResults());
// Find all Guacamole users underneath base DN
LDAPSearchResults results = ldapConnection.search(
@@ -93,7 +97,8 @@ public class UserService {
LDAPConnection.SCOPE_SUB,
"(&(objectClass=*)(" + escapingService.escapeLDAPSearchFilter(usernameAttribute) + "=*))",
null,
false
false,
constraints
);
// Read all visible users