private String generateLDAPQuery(String username) throws GuacamoleException {
  List<String> usernameAttributes=confService.getUsernameAttributes();
  StringBuilder ldapQuery=new StringBuilder("(&(objectClass=*)");
  if (usernameAttributes.size() > 1)   ldapQuery.append("(|");
  for (  String usernameAttribute : usernameAttributes) {
    ldapQuery.append("(");
    ldapQuery.append(escapingService.escapeLDAPSearchFilter(usernameAttribute));
    ldapQuery.append("=");
    ldapQuery.append(escapingService.escapeLDAPSearchFilter(username));
    ldapQuery.append(")");
  }
  if (usernameAttributes.size() > 1)   ldapQuery.append(")");
  ldapQuery.append(")");
  return ldapQuery.toString();
}

private String generateLDAPQuery ( String username ) throws GuacamoleException { List < String > usernameAttributes = confService . getUsernameAttributes ( ) ; StringBuilder ldapQuery = new StringBuilder ( "(&(objectClass=*)" ) ; if ( usernameAttributes . size ( ) > 1 ) ldapQuery . append ( "(|" ) ; for ( String usernameAttribute : usernameAttributes ) { ldapQuery . append ( "(" ) ; ldapQuery . append ( escapingService . escapeLDAPSearchFilter ( usernameAttribute ) ) ; ldapQuery . append ( "=" ) ; ldapQuery . append ( escapingService . escapeLDAPSearchFilter ( username ) ) ; ldapQuery . append ( ")" ) ; } if ( usernameAttributes . size ( ) > 1 ) ldapQuery . append ( ")" ) ; ldapQuery . append ( ")" ) ; return ldapQuery . toString ( ) ; }
generates a properly - escaped ldap query which finds all objects having at least one username attribute set to the specified username , where the possible username attributes are defined within guacamole . properties .
