handavid commented on code in PR #1522:
URL: https://github.com/apache/knox/pull/1522#discussion_r4621645170


##########
gateway-server/src/main/java/org/apache/knox/gateway/services/ldap/interceptor/LDAPRolesLookupInterceptor.java:
##########
@@ -277,18 +296,125 @@ private EntryFilteringCursor 
handleSearch(SearchOperationContext ctx) throws Lda
             
ctx.setReturningAttributes(withAttributes(originalReturningAttributes, 
augmentedAttributes));
         }
 
+        int numUserAndGroupEntries = 0;
         final List<Entry> entries = new ArrayList<>();
         try (EntryFilteringCursor cursor = next(ctx)) {
             while (cursor.next()) {
+                Entry entry = cursor.get();
+                if (LdapUtils.isUserEntry(entry) || 
LdapUtils.isGroupEntry(entry)) {
+                    numUserAndGroupEntries++;
+                }
                 entries.add(cursor.get());
             }
         } catch (Exception e) {
             LOG.ldapRolesLookupFailed(LdapUtils.extractGroupName(ctx.getDn()), 
e);
             throw new LdapException(e);
         }
 
+        // Populating the roles through lookup results in one lookup request 
per entry.
+        // It is more efficient to list all the roles when the number of 
entries is large.

Review Comment:
   I added a bulk call and left the calculation as num entries > num roles. I'm 
not concerned about the +-1 for simplicity of the code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to