-
Notifications
You must be signed in to change notification settings - Fork 36
Also find groups added through groupOfUniqueNames #78
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -16,14 +16,17 @@ def find_user(uid, base_dn = @base) | |||
| # return an ldap user with groups attached | ||||
| # note : this method is not particularly fast for large ldap systems | ||||
| def find_user_groups(uid) | ||||
| user = find_user(uid).first | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this somehow yell if there's more than 1 user?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can it happen? I was living under the impression that the uid we get should uniquely identify a single object within the subtree set by
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It wouldn't be a good practice, but if you organize your LDAP tree with different organization units it can happen. Concrete example: let's say your base is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There can be multiple entries with the same uid (as opposed to dn) |
||||
| groups = [] | ||||
| @ldap.search( | ||||
| :filter => Net::LDAP::Filter.eq('memberuid', uid), | ||||
| :filter => user_group_filter(uid, user[:dn].first), | ||||
| :base => @group_base, :attributes => ["cn"] | ||||
| ).each do |entry| | ||||
| groups << entry[:cn][0] | ||||
| end | ||||
| groups | ||||
| rescue UIDNotFoundException | ||||
| return [] | ||||
| end | ||||
|
|
||||
| def times_in_groups(uid, gids, all) | ||||
|
|
@@ -52,4 +55,12 @@ class UIDNotFoundException < LdapFluff::Error | |||
|
|
||||
| class GIDNotFoundException < LdapFluff::Error | ||||
| end | ||||
|
|
||||
| private | ||||
|
|
||||
| def user_group_filter(uid, user_dn) | ||||
| unique_filter = Net::LDAP::Filter.eq('uniquemember', user_dn) & | ||||
| Net::LDAP::Filter.eq('objectClass', 'groupOfUniqueNames') | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's also ldap_fluff/lib/ldap_fluff/posix.rb Line 24 in 77a387a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are multiple group-like object types in LDAP. I think it's a high level decision what we support (and document!) |
||||
| Net::LDAP::Filter.eq('memberuid', uid) | unique_filter | ||||
| end | ||||
| end | ||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was digging deeper on what should be done for POSIX. If we assume this maps to the nss-pam-ldap implementation then according to https://arthurdejong.org/nss-pam-ldapd/README this is the spec:
If we look at the method, then we see there is already a constructor parameter that determines
@attr_login, which is not respected right now.Reading the documentation it's not clear to me if
memberUidormemberis an XOR, but it looks likegroupOfUniqueNamesis not part of the posix spec at all.In #72 (comment) I already noted that I think it's a different flavor we should support. Most likely an expansion of the FreeIPA flavor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about instead of exposing this as a brand new flavor, we allow enabling the use of groupOfNames/groupOfUniqueNames in a similar way how we handle nis netgroups? Something along the lines of adamruzicka/ldap_fluff@unique-group-search...adamruzicka:ldap_fluff:unique-group-search-ext
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the code I think that could work. For
LdapFluff::Posix::MemberServiceI was debating a subclass but it looks like it's not strictly needed.