Program: 52308
Project: 52308
Buggy source:
/** 
 * Returns a list of all DNs corresponding to the users having the given username. If multiple username attributes are defined, or if uniqueness is not enforced across the username attribute, it is possible that this will return multiple DNs.
 * @param ldapConnection The connection to the LDAP server to use when querying user DNs.
 * @param username The username of the user whose corresponding user account DNs are to be retrieved.
 * @return A list of all DNs corresponding to the users having the given username. If no such DNs exist, this list will be empty.
 * @throws GuacamoleException If an error occurs while querying the user DNs, or if the username attribute property cannot be parsed within guacamole.properties.
 */
public List<String> getUserDNs(LDAPConnection ldapConnection,String username) throws GuacamoleException {
  try {
    List<String> userDNs=new ArrayList<String>();
    LDAPSearchResults results=ldapConnection.search(confService.getUserBaseDN(),LDAPConnection.SCOPE_SUB,generateLDAPQuery(username),null,false,confService.getLDAPSearchConstraints());
    while (results.hasMore()) {
      try {
        LDAPEntry entry=results.next();
        userDNs.add(entry.getDN());
      }
 catch (      LDAPReferralException e) {
        if (confService.getFollowReferrals()) {
          logger.error("String_Node_Str",e.getMessage());
          logger.debug("String_Node_Str",e);
          throw new GuacamoleServerException("String_Node_Str",e);
        }
 else {
          logger.warn("String_Node_Str",e.getMessage());
          logger.debug("String_Node_Str",e);
        }
      }
    }
    return userDNs;
  }
 catch (  LDAPException e) {
    throw new GuacamoleServerException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Returns a list of all DNs corresponding to the users having the given username. If multiple username attributes are defined, or if uniqueness is not enforced across the username attribute, it is possible that this will return multiple DNs.
 * @param ldapConnection The connection to the LDAP server to use when querying user DNs.
 * @param username The username of the user whose corresponding user account DNs are to be retrieved.
 * @return A list of all DNs corresponding to the users having the given username. If no such DNs exist, this list will be empty.
 * @throws GuacamoleException If an error occurs while querying the user DNs, or if the username attribute property cannot be parsed within guacamole.properties.
 */
public List<String> getUserDNs(LDAPConnection ldapConnection,String username) throws GuacamoleException {
  try {
    List<String> userDNs=new ArrayList<String>();
    LDAPSearchResults results=ldapConnection.search(confService.getUserBaseDN(),LDAPConnection.SCOPE_SUB,generateLDAPQuery(username),null,false,confService.getLDAPSearchConstraints());
    while (results.hasMore()) {
      try {
        LDAPEntry entry=results.next();
        userDNs.add(entry.getDN());
      }
 catch (      LDAPReferralException e) {
        if (confService.getFollowReferrals()) {
          logger.error("String_Node_Str",e.getFailedReferral());
          logger.debug("String_Node_Str",e);
          throw new GuacamoleServerException("String_Node_Str",e);
        }
 else {
          logger.warn("String_Node_Str",e.getMessage());
          logger.debug("String_Node_Str",e);
        }
      }
    }
    return userDNs;
  }
 catch (  LDAPException e) {
    throw new GuacamoleServerException("String_Node_Str",e);
  }
}