GUACAMOLE-234: Correct counter for referral hops.

This commit is contained in:
Nick Couchman
2018-12-14 21:02:14 -05:00
committed by Virtually Nick
parent 7a17b7f935
commit 7825f57b99
2 changed files with 9 additions and 6 deletions

View File

@@ -169,6 +169,9 @@ public class ObjectQueryService {
* *
* @param query * @param query
* The LDAP query to execute. * The LDAP query to execute.
*
* @param searchHop
* The level of depth for this search, used for tracking referrals.
* *
* @return * @return
* A list of all results accessible to the user currently bound under * A list of all results accessible to the user currently bound under
@@ -180,7 +183,7 @@ public class ObjectQueryService {
* guacamole.properties. * guacamole.properties.
*/ */
public List<Entry> search(LdapNetworkConnection ldapConnection, public List<Entry> search(LdapNetworkConnection ldapConnection,
Dn baseDN, ExprNode query) throws GuacamoleException { Dn baseDN, ExprNode query, int searchHop) throws GuacamoleException {
logger.debug("Searching \"{}\" for objects matching \"{}\".", baseDN, query); logger.debug("Searching \"{}\" for objects matching \"{}\".", baseDN, query);
@@ -205,11 +208,10 @@ public class ObjectQueryService {
else if (results.isReferral() && request.isFollowReferrals()) { else if (results.isReferral() && request.isFollowReferrals()) {
Referral referral = results.getReferral(); Referral referral = results.getReferral();
int referralHop = 0;
for (String url : referral.getLdapUrls()) { for (String url : referral.getLdapUrls()) {
LdapNetworkConnection referralConnection = ldapService.referralConnection( LdapNetworkConnection referralConnection = ldapService.referralConnection(
new LdapUrl(url), ldapConnectionConfig, referralHop++); new LdapUrl(url), ldapConnectionConfig, searchHop++);
entries.addAll(search(referralConnection, baseDN, query)); entries.addAll(search(referralConnection, baseDN, query, searchHop));
} }
} }
@@ -270,7 +272,7 @@ public class ObjectQueryService {
ExprNode filter, Collection<String> attributes, String attributeValue) ExprNode filter, Collection<String> attributes, String attributeValue)
throws GuacamoleException { throws GuacamoleException {
ExprNode query = generateQuery(filter, attributes, attributeValue); ExprNode query = generateQuery(filter, attributes, attributeValue);
return search(ldapConnection, baseDN, query); return search(ldapConnection, baseDN, query, 0);
} }
/** /**

View File

@@ -125,7 +125,8 @@ public class ConnectionService {
// looking for direct membership in the guacConfigGroup // looking for direct membership in the guacConfigGroup
// and possibly any groups the user is a member of that are // and possibly any groups the user is a member of that are
// referred to in the seeAlso attribute of the guacConfigGroup. // referred to in the seeAlso attribute of the guacConfigGroup.
List<Entry> results = queryService.search(ldapConnection, configurationBaseDN, connectionSearchFilter); List<Entry> results = queryService.search(ldapConnection,
configurationBaseDN, connectionSearchFilter, 0);
// Return a map of all readable connections // Return a map of all readable connections
return queryService.asMap(results, (entry) -> { return queryService.asMap(results, (entry) -> {