-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fixed dynamic group ldap access #23344
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -468,16 +468,17 @@ public function getUserGroups($uid) { | |
| // apply filter via ldap search to see if this user is in this | ||
| // dynamic group | ||
| $userMatch = $this->access->readAttribute( | ||
| $uid, | ||
| $userDN, | ||
| $this->access->connection->ldapUserDisplayName, | ||
| $memberUrlFilter | ||
| ); | ||
| if ($userMatch !== false) { | ||
| // match found so this user is in this group | ||
| $pos = strpos($dynamicGroup['dn'][0], ','); | ||
| if ($pos !== false) { | ||
| $membershipGroup = substr($dynamicGroup['dn'][0],3,$pos-3); | ||
| $groups[] = $membershipGroup; | ||
| $groupName = $this->access->dn2groupname($dynamicGroup['dn'][0]); | ||
| if(is_string($groupName)) { | ||
| // be sure to never return false if the dn could not be | ||
| // resolved to a name, for whatever reason. | ||
| $groups[] = $groupName; | ||
| } | ||
| } | ||
| } else { | ||
|
|
@@ -529,11 +530,12 @@ public function getUserGroups($uid) { | |
| } | ||
|
|
||
| if(isset($this->cachedGroupsByMember[$uid])) { | ||
| $groups = $this->cachedGroupsByMember[$uid]; | ||
| $groups[] = $this->cachedGroupsByMember[$uid]; | ||
| } else { | ||
| $groups = array_values($this->getGroupsByMember($uid)); | ||
| $groups = $this->access->ownCloudGroupNames($groups); | ||
| $this->cachedGroupsByMember[$uid] = $groups; | ||
| $groupsByMember = array_values($this->getGroupsByMember($uid)); | ||
| $groupsByMember = $this->access->ownCloudGroupNames($groupsByMember); | ||
|
Contributor
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. this is also the only place where $this->cachedGroupsByMember is used. By removing this, all other tracks $this->cachedGroupsByMember should also go (e.g. its definiton) |
||
| $this->cachedGroupsByMember[$uid] = $groupsByMember; | ||
| $groups = array_merge($groups, $groupsByMember); | ||
| } | ||
|
|
||
| if($primaryGroup !== false) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this and following line is still necessary, or did I oversee anything?
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.
Of course it should not overwrite, but append to $groups
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.
@blizzz
I don't know (yet) how your caching is working? Is that cache in the DB or in memory. I have the impression (can't prove it yet) that something goes wrong with the caching because of the cachekeys. At the top of the function the cachekey is generate with the uid and then the cache is read, but at the end of the method, the cachedGroupByMember is written with the userDN (in our case).
I'm trying to put back the cache code in place and just noticed that although the dynamic groups are now working in my code, the "static" groups (based on "uniquemember") are no longer being added to the groups list...
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.
only exists on run-time. It is a member array of the class instance.
What should not be kept is the caching part, but the fetching of the other groups.
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.
@blizzz
I think I've got the groups working (both dynamic and static) ... but I need to do some more tests and get back on Monday.
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.
@alexweirig sounds great, thank you.