Skip to content
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

Problem with dynamic ldap group processing in 9.0.0 #23081

Closed
alexweirig opened this issue Mar 10, 2016 · 10 comments
Closed

Problem with dynamic ldap group processing in 9.0.0 #23081

alexweirig opened this issue Mar 10, 2016 · 10 comments

Comments

@alexweirig
Copy link
Contributor

@blizzz @PVince81
Hello,

after upgrading to 9.0.0 the dynamic ldap group processing is no longer correctly.

I've debugged the group_ldap.php and getUserGroups method and found the following 2 issues:

  1. when doing the access->readAttribute for the dynamic group filter, the $uid variable is used. I think the $userDN must be used in order to have LDAP find anything
  2. when the user is member of a dynamic group, the group name conversion can be simplified:
    $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;
    }
  3. after all the processing has been done, at the end of the method, some cache tests are performed:
    if(isset($this->cachedGroupsByMember[$uid])) {
    (1) $groups = $this->cachedGroupsByMember[$uid];
    } else {
    (2) $groups = array_values($this->getGroupsByMember($uid));
    (3) $groups = $this->access->ownCloudGroupNames($groups);
    $this->cachedGroupsByMember[$uid] = $groups;
    }
    if I leave this tests in the code, the dynamic groups are not working. After this cache test, the group list for the user is empty even though the dynamic groups had been correctly retrieved previously.
    If I comment these lines out, everything seems to work fine.

Why is the cache test only performed at the end of method?
Why would the dynamic groups not be in the cache?
Line (1) overwrites the content (groups found previously) of the groups array, isn't it?
Is line (3) not overwriting the result of line (2)?

I'm not sure if removing the cache processing can cause other problems but I don't understand why the cache is only retrieved at the end or at least why the results from the cache are not simply added to the existing groups array rather than overwriting the contents of the array.

I've attached my version of the getUserGroups method showing my debug code and my comments.

If this sounds OK for you I can try to do a pull request again.
getUserGroups.txt

Cheers,

Alex

@alexweirig
Copy link
Contributor Author

All this processing makes displaying the user list extremely slow. I've created a screen capture showing how the user list is build and showing the logging that is going on during the process.
I've also attached the owncloud.log file being produced during this process.

The screencast can be downloaded here:
https://owncloud.technolink.lu/index.php/s/KyXYucDljOb2rnR

owncloud.log_save.zip

@PVince81
Copy link
Contributor

@blizzz please have a look

@PVince81 PVince81 added this to the 9.0.1-current-maintenance milestone Mar 14, 2016
@blizzz
Copy link
Contributor

blizzz commented Mar 16, 2016

The screencast can be downloaded here:
https://owncloud.technolink.lu/index.php/s/KyXYucDljOb2rnR

Just tells me "File not found"

@alexweirig
Copy link
Contributor Author

@blizzz
Sorry, the file was "unshared".
I've shared it again with this link

@alexweirig
Copy link
Contributor Author

@blizzz
Copy link
Contributor

blizzz commented Mar 16, 2016

  1. when doing the access->readAttribute for the dynamic group filter, the $uid variable is used. I think the $userDN must be used in order to have LDAP find anything

I agree with you

  1. when the user is member of a dynamic group, the group name conversion can be simplified

Looks good as well and would improve readability.

  1. after all the processing has been done, at the end of the method, some cache tests are performed:

Doh. This makes reading the dynamic groups totally useless, worsening performance since it is done any time. And if the cache is not set, the groups are being re-fetched in the else part, ignoring dynamic members. How did this slip our eyes at all?

However, this does not make sense here anyway, just as you say it yourself

Why is the cache test only performed at the end of method?

There are more checks. On is done directly at the beginning:

        $cacheKey = 'getUserGroups'.$uid;
        if($this->access->connection->isCached($cacheKey)) {
            return $this->access->connection->getFromCache($cacheKey);
        }

This one here in particular is an extra check on groups by member. But I am not entirely sure why we have the extra check in place here, it seems unnecessary. Also looking at the rest of the code in this class. Bit rot, possibly.

I'm not sure if removing the cache processing can cause other problems but I don't understand why the cache is only retrieved at the end or at least why the results from the cache are not simply added to the existing groups array rather than overwriting the contents of the array.

I think we can remove this cache check and the $this->cachedGroupsByMember array in general. However, calling and processing the results from $this->getGroupsByMember($uid) is necessary. Would you like to open a PR, so we can test it? D

All this processing makes displaying the user list extremely slow. I've created a screen capture showing how the user list is build and showing the logging that is going on during the process.

Is this before or after the changes?

@alexweirig
Copy link
Contributor Author

@blizzz
Thanks for the feedback.

Yes, I'll try to do a PR ...

Is this before or after the changes?
This is (unfortunately) after the changes ...

@blizzz
Copy link
Contributor

blizzz commented Mar 21, 2016

Fix in #23344

@ghost ghost modified the milestones: 9.1-current, 9.0.1 Apr 8, 2016
@PVince81
Copy link
Contributor

PVince81 commented Jun 1, 2016

Backport PR is here, needs review and testing: #24950

@lock
Copy link

lock bot commented Aug 4, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants