Github user mike-jumper commented on a diff in the pull request:

    
https://github.com/apache/incubator-guacamole-client/pull/202#discussion_r146657553
  
    --- Diff: 
extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/user/UserService.java
 ---
    @@ -107,19 +108,37 @@ private void putAllUsers(Map<String, User> users, 
LDAPConnection ldapConnection,
                 // Read all visible users
                 while (results.hasMore()) {
     
    -                LDAPEntry entry = results.next();
    +                try {
    +
    +                    LDAPEntry entry = results.next();
    +
    +                    // Get username from record
    +                    LDAPAttribute username = 
entry.getAttribute(usernameAttribute);
    +                    if (username == null) {
    +                        logger.warn("Queried user is missing the username 
attribute \"{}\".", usernameAttribute);
    +                        continue;
    +                    }
    +
    +                    // Store user using their username as the identifier
    +                    String identifier = username.getStringValue();
    +                    if (users.put(identifier, new SimpleUser(identifier)) 
!= null)
    +                        logger.warn("Possibly ambiguous user account: 
\"{}\".", identifier);
     
    -                // Get username from record
    -                LDAPAttribute username = 
entry.getAttribute(usernameAttribute);
    -                if (username == null) {
    -                    logger.warn("Queried user is missing the username 
attribute \"{}\".", usernameAttribute);
    -                    continue;
                     }
     
    -                // Store user using their username as the identifier
    -                String identifier = username.getStringValue();
    -                if (users.put(identifier, new SimpleUser(identifier)) != 
null)
    -                    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.getFailedReferral());
    +                        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;
    --- End diff --
    
    Being the last statement in the loop, this `continue` has no effect.


---

Reply via email to