Skip to content

Recursive group member search strategy #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 26, 2014
Merged

Recursive group member search strategy #64

merged 10 commits into from
Nov 26, 2014

Conversation

mtodd
Copy link
Member

@mtodd mtodd commented Nov 25, 2014

This adds a recursive search strategy to find all members of a given group, including nested groups.

This implementation has three desirable qualities for a search strategy like this:

  1. tracks entries already found so circular or repeated members are queried for exactly once
  2. defines a maximum (configurable) depth to recurse
  3. queries for the required attributes and nothing else

Unfortunately, member attributes are DNs which requires a search per DN, resulting in as many queries as there are unique DNs to search for, resulting in potentially huge query volume. One option is to experiment with querying based on the RDN, but that could result in ill-defined behavior.

Still to do:

  • generalize for various member attributes (currently hardcoded to member)
  • more tests
  • experiment with extracting RDNs from DNs to do bulk searches for member entries (separate PR)
  • benchmark against Group#members and Group#subgroups (classic strategy) (separate issue)

cc @jch @github/ldap

@mtodd mtodd self-assigned this Nov 25, 2014
options[:size] = 1
options[:scope] = Net::LDAP::SearchScope_BaseObject
options[:attributes] ||= []
search(options).first
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker since this was here previously, but does it feel misleading that the method is named bind and what it actually does is search?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jch yeah, it's definitely confusing. I think I'm going to make some changes to the API for membership validators in this release which will eventually be breaking so it might be a good time to fix this (in a follow up PR).

@jch
Copy link
Contributor

jch commented Nov 25, 2014

Tests look good. I liked your inline comments on the recursive strategy. It's more verbose, but made it much easier to understand. 👍 to ship unless you had specific areas you'd like me to review

@mtodd
Copy link
Member Author

mtodd commented Nov 25, 2014

@jch right on. I'm going to generalize the attributes since it's hardcoded right now, along with better tests, and merge this. The other items can be worked on separately, after this is merged.

entries.concat entries_by_dn(dns) unless dns.empty?

entries
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this method to handle handle the various member attributes better.

@mtodd
Copy link
Member Author

mtodd commented Nov 26, 2014

Pretty happy with where this is at for now. @jch one last 👓 before merge?

mtodd added a commit that referenced this pull request Nov 26, 2014
Recursive group member search strategy
@mtodd mtodd merged commit a1276ff into master Nov 26, 2014
@mtodd mtodd deleted the recursive-membership branch November 26, 2014 01:05
@jch
Copy link
Contributor

jch commented Dec 3, 2014

🤘

@mtodd mtodd mentioned this pull request Dec 3, 2014
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants