Github user necouchman commented on a diff in the pull request:

    https://github.com/apache/guacamole-client/pull/345#discussion_r241928440
  
    --- Diff: 
extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/ObjectQueryService.java
 ---
    @@ -188,46 +183,50 @@ public String generateQuery(String filter,
          *     information required to execute the query cannot be read from
          *     guacamole.properties.
          */
    -    public List<LDAPEntry> search(LDAPConnection ldapConnection,
    -            String baseDN, String query) throws GuacamoleException {
    +    public List<Entry> search(LdapConnection ldapConnection,
    +            Dn baseDN, ExprNode query) throws GuacamoleException {
     
             logger.debug("Searching \"{}\" for objects matching \"{}\".", 
baseDN, query);
     
             try {
     
    +            LdapConnectionConfig ldapConnectionConfig =
    +                    ((LdapNetworkConnection) ldapConnection).getConfig();
    +            
                 // Search within subtree of given base DN
    -            LDAPSearchResults results = ldapConnection.search(baseDN,
    -                    LDAPConnection.SCOPE_SUB, query, null, false,
    -                    confService.getLDAPSearchConstraints());
    +            SearchRequest request = ldapService.getSearchRequest(baseDN,
    +                    query);
    +            
    +            SearchCursor results = ldapConnection.search(request);
     
                 // Produce list of all entries in the search result, 
automatically
                 // following referrals if configured to do so
    -            List<LDAPEntry> entries = new ArrayList<>(results.getCount());
    -            while (results.hasMore()) {
    +            List<Entry> entries = new ArrayList<>();
    +            while (results.next()) {
     
    -                try {
    -                    entries.add(results.next());
    +                Response response = results.get();
    +                if (response instanceof SearchResultEntry) {
    --- End diff --
    
    Reworked to avoid this using the calls you mentioned.


---

Reply via email to