mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUACAMOLE-79: Adding an option to allow the default LDAP result size limit (1000) to be overridden
This commit is contained in:
@@ -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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -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"; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,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 com.novell.ldap.LDAPSearchConstraints;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -86,6 +87,9 @@ public class UserService {
|
|||||||
String usernameAttribute) throws GuacamoleException {
|
String usernameAttribute) throws GuacamoleException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Set search limits
|
||||||
|
LDAPSearchConstraints constraints = new LDAPSearchConstraints();
|
||||||
|
constraints.setMaxResults(confService.getMaxResults());
|
||||||
|
|
||||||
// Find all Guacamole users underneath base DN
|
// Find all Guacamole users underneath base DN
|
||||||
LDAPSearchResults results = ldapConnection.search(
|
LDAPSearchResults results = ldapConnection.search(
|
||||||
@@ -93,7 +97,8 @@ public class UserService {
|
|||||||
LDAPConnection.SCOPE_SUB,
|
LDAPConnection.SCOPE_SUB,
|
||||||
"(&(objectClass=*)(" + escapingService.escapeLDAPSearchFilter(usernameAttribute) + "=*))",
|
"(&(objectClass=*)(" + escapingService.escapeLDAPSearchFilter(usernameAttribute) + "=*))",
|
||||||
null,
|
null,
|
||||||
false
|
false,
|
||||||
|
constraints
|
||||||
);
|
);
|
||||||
|
|
||||||
// Read all visible users
|
// Read all visible users
|
||||||
|
Reference in New Issue
Block a user