mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-243: Finish up changes to deal with LDAP referrals, both in UserServer and ConnectionServer classes, along with global changes in LDAPConnectionService class.
This commit is contained in:
committed by
Nick Couchman
parent
d98cdd2917
commit
242cfbaf85
@@ -118,13 +118,16 @@ public class LDAPConnectionService {
|
||||
if (ldapConstraints == null)
|
||||
ldapConstraints = new LDAPConstraints();
|
||||
|
||||
// Set whether or not we follow referrals, and max hops
|
||||
// Set whether or not we follow referrals
|
||||
ldapConstraints.setReferralFollowing(confService.getFollowReferrals());
|
||||
String refAuthMethod = confService.getReferralAuthentication();
|
||||
|
||||
// If the referral auth method is set to bind, we set it using the existing
|
||||
// username and password.
|
||||
String refAuthMethod = confService.getReferralAuthentication();
|
||||
if (refAuthMethod != null && refAuthMethod.equals("bind"))
|
||||
ldapConstraints.setReferralHandler(new ReferralAuthHandler(userDN, password));
|
||||
|
||||
// Set the maximum number of referrals we follow
|
||||
ldapConstraints.setHopLimit(confService.getMaxReferralHops());
|
||||
|
||||
// Set timelimit to wait for LDAP operations, converting to ms
|
||||
|
@@ -24,6 +24,7 @@ import com.novell.ldap.LDAPAttribute;
|
||||
import com.novell.ldap.LDAPConnection;
|
||||
import com.novell.ldap.LDAPEntry;
|
||||
import com.novell.ldap.LDAPException;
|
||||
import com.novell.ldap.LDAPReferralException;
|
||||
import com.novell.ldap.LDAPSearchResults;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
@@ -129,6 +130,8 @@ public class ConnectionService {
|
||||
Map<String, Connection> connections = new HashMap<String, Connection>();
|
||||
while (results.hasMore()) {
|
||||
|
||||
try {
|
||||
|
||||
LDAPEntry entry = results.next();
|
||||
|
||||
// Get common name (CN)
|
||||
@@ -188,6 +191,22 @@ public class ConnectionService {
|
||||
|
||||
}
|
||||
|
||||
// Deal with issues following LDAP referrals
|
||||
catch (LDAPReferralException e) {
|
||||
if (confService.getFollowReferrals()) {
|
||||
logger.error("Could not follow referral.", e.getMessage());
|
||||
logger.debug("Error encountered trying to follow referral.", e);
|
||||
throw new GuacamoleServerException("Could not follow LDAP referral.", e);
|
||||
}
|
||||
else {
|
||||
logger.warn("Given a referral, but referrals are disabled.", e.getMessage());
|
||||
logger.debug("Got a referral, but configured to not follow them.", e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Return map of all connections
|
||||
return connections;
|
||||
|
||||
@@ -251,9 +270,24 @@ public class ConnectionService {
|
||||
// The guacConfig group uses the seeAlso attribute to refer
|
||||
// to these other groups
|
||||
while (userRoleGroupResults.hasMore()) {
|
||||
try {
|
||||
LDAPEntry entry = userRoleGroupResults.next();
|
||||
connectionSearchFilter.append("(seeAlso=").append(escapingService.escapeLDAPSearchFilter(entry.getDN())).append(")");
|
||||
}
|
||||
|
||||
catch (LDAPReferralException e) {
|
||||
if (confService.getFollowReferrals()) {
|
||||
logger.error("Could not follow referral.", e.getMessage());
|
||||
logger.debug("Error encountered trying to follow referral.", e);
|
||||
throw new GuacamoleServerException("Could not follow LDAP referral.", e);
|
||||
}
|
||||
else {
|
||||
logger.warn("Given a referral, but referrals are disabled.", e.getMessage());
|
||||
logger.debug("Got a referral, but configured to not follow them.", e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Complete the search filter.
|
||||
|
@@ -125,15 +125,17 @@ public class UserService {
|
||||
logger.warn("Possibly ambiguous user account: \"{}\".", identifier);
|
||||
|
||||
}
|
||||
|
||||
// Deal with errors trying to follow referrals
|
||||
catch (LDAPReferralException e) {
|
||||
if (confService.getFollowReferrals()) {
|
||||
logger.error("Could not follow referral.", e.getMessage());
|
||||
logger.debug("Error encountered trying to follow referral.", e);
|
||||
throw new GuacamoleException("Could not follow LDAP referral.");
|
||||
throw new GuacamoleServerException("Could not follow LDAP referral.", e);
|
||||
}
|
||||
else {
|
||||
logger.warn("Encountered a referral, but not following it.", e.getMessage());
|
||||
logger.debug("Got a referral, but not configured to follow it.", e);
|
||||
logger.warn("Given a referral, but referrals are disabled.", e.getMessage());
|
||||
logger.debug("Got a referral, but configured to not follow them.", e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -284,10 +286,26 @@ public class UserService {
|
||||
|
||||
// Add all DNs for found users
|
||||
while (results.hasMore()) {
|
||||
try {
|
||||
LDAPEntry entry = results.next();
|
||||
userDNs.add(entry.getDN());
|
||||
}
|
||||
|
||||
// Deal with errors following referrals
|
||||
catch (LDAPReferralException e) {
|
||||
if (confService.getFollowReferrals()) {
|
||||
logger.error("Error trying to follow a referral.", e.getMessage());
|
||||
logger.debug("Encountered an error trying to follow a referral.", e);
|
||||
throw new GuacamoleServerException("Failed while trying to follow referrals.", e);
|
||||
}
|
||||
else {
|
||||
logger.warn("Given a referral, not following it.", e.getMessage());
|
||||
logger.debug("Given a referral, but configured to not follow them.", e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return all discovered DNs (if any)
|
||||
return userDNs;
|
||||
|
||||
|
Reference in New Issue
Block a user