core icon indicating copy to clipboard operation
core copied to clipboard

LDAP: Domain Users are not being loaded with User Filter

Open sbelov1 opened this issue 11 years ago • 144 comments

Environment: OC v7.0.4 on apache CentOS 6.5 php 5.4.32 MySQL AD LDAP Description: Customer is attempting to select just a Domain Users group from the User Filter, however only 2 (as oppose to 200) are shown. As a workaround we have to either use a different group or allow all the groups to login with OC.

Here's the log excerpt:

{"app":"PHP","message":"ldap_search(): Partial search results returned: Sizelimit exceeded at \/var\/www\/html\/owncloud\/apps\/user_ldap\/lib\/ldap.php#252","level":3,"time":"2015-01-20T17:24:20+00:00"}
{"app":"PHP","message":"ldap_search(): Partial search results returned: Sizelimit exceeded at \/var\/www\/html\/owncloud\/apps\/user_ldap\/lib\/ldap.php#252","level":3,"time":"2015-01-20T17:24:20+00:00"}
{"app":"PHP","message":"ldap_search(): Partial search results returned: Sizelimit exceeded at \/var\/www\/html\/owncloud\/apps\/user_ldap\/lib\/ldap.php#252","level":3,"time":"2015-01-20T17:24:21+00:00"}
{"app":"PHP","message":"ldap_search(): Partial search results returned: Sizelimit exceeded at \/var\/www\/html\/owncloud\/apps\/user_ldap\/lib\/ldap.php#252","level":3,"time":"2015-01-20T17:24:31+00:00"}
{"app":"PHP","message":"ldap_search(): Partial search results returned: Sizelimit exceeded at \/var\/www\/html\/owncloud\/apps\/user_ldap\/lib\/ldap.php#252","level":3,"time":"2015-01-20T17:24:42+00:00"}
{"app":"PHP","message":"ldap_search(): Partial search results returned: Sizelimit exceeded at \/var\/www\/html\/owncloud\/apps\/user_ldap\/lib\/ldap.php#252","level":3,"time":"2015-01-20T17:24:59+00:00"}
{"app":"PHP","message":"ldap_search(): Partial search results returned: Sizelimit exceeded at \/var\/www\/html\/owncloud\/apps\/user_ldap\/lib\/ldap.php#252","level":3,"time":"2015-01-20T17:25:03+00:00"}
{"app":"PHP","message":"ldap_search(): Partial search results returned: Sizelimit exceeded at \/var\/www\/html\/owncloud\/apps\/user_ldap\/lib\/ldap.php#252","level":3,"time":"2015-01-20T17:25:04+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/apps\/user_ldap\/group_ldap.php#477","level":3,"time":"2015-01-20T17:31:15+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/lib\/private\/user\/manager.php#100","level":3,"time":"2015-01-20T17:31:15+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/lib\/private\/user\/database.php#209","level":3,"time":"2015-01-20T17:31:15+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/3rdparty\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Statement.php#138","level":3,"time":"2015-01-20T17:31:15+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/lib\/private\/user\/database.php#250","level":3,"time":"2015-01-20T17:31:15+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/apps\/user_ldap\/user_ldap.php#136","level":3,"time":"2015-01-20T17:31:15+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/apps\/user_ldap\/lib\/user\/manager.php#140","level":3,"time":"2015-01-20T17:31:15+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/apps\/user_ldap\/lib\/user\/manager.php#142","level":3,"time":"2015-01-20T17:31:15+00:00"}
{"app":"PHP","message":"ldap_explode_dn() expects parameter 1 to be string, array given at \/var\/www\/html\/owncloud\/apps\/user_ldap\/lib\/ldap.php#252","level":3,"time":"2015-01-20T17:31:15+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/3rdparty\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Statement.php#138","level":3,"time":"2015-01-20T17:31:15+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/3rdparty\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Statement.php#138","level":3,"time":"2015-01-20T17:31:15+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/apps\/user_ldap\/user_ldap.php#142","level":3,"time":"2015-01-20T17:31:15+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/apps\/user_ldap\/user_ldap.php#144","level":3,"time":"2015-01-20T17:31:15+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/lib\/private\/user\/manager.php#100","level":3,"time":"2015-01-20T17:31:17+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/lib\/private\/user\/database.php#209","level":3,"time":"2015-01-20T17:31:17+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/3rdparty\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Statement.php#138","level":3,"time":"2015-01-20T17:31:17+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/lib\/private\/user\/database.php#250","level":3,"time":"2015-01-20T17:31:17+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/apps\/user_ldap\/user_ldap.php#136","level":3,"time":"2015-01-20T17:31:17+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/apps\/user_ldap\/user_ldap.php#137","level":3,"time":"2015-01-20T17:31:17+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/lib\/private\/user\/manager.php#100","level":3,"time":"2015-01-20T17:31:21+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/lib\/private\/user\/database.php#209","level":3,"time":"2015-01-20T17:31:21+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/3rdparty\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Statement.php#138","level":3,"time":"2015-01-20T17:31:21+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/lib\/private\/user\/database.php#250","level":3,"time":"2015-01-20T17:31:21+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/apps\/user_ldap\/user_ldap.php#136","level":3,"time":"2015-01-20T17:31:21+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/apps\/user_ldap\/user_ldap.php#137","level":3,"time":"2015-01-20T17:31:21+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/lib\/private\/user\/manager.php#100","level":3,"time":"2015-01-20T17:31:22+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/lib\/private\/user\/database.php#209","level":3,"time":"2015-01-20T17:31:22+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/3rdparty\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Statement.php#138","level":3,"time":"2015-01-20T17:31:22+00:00"}
{"app":"PHP","message":"Illegal offset type in isset or empty at \/var\/www\/html\/owncloud\/lib\/private\/user\/database.php#250","level":3,"time":"2015-01-20T17:31:22+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/apps\/user_ldap\/user_ldap.php#136","level":3,"time":"2015-01-20T17:31:22+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/apps\/user_ldap\/user_ldap.php#137","level":3,"time":"2015-01-20T17:31:22+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/apps\/user_ldap\/group_ldap.php#561","level":3,"time":"2015-01-20T17:32:11+00:00"}
{"app":"PHP","message":"Array to string conversion at \/var\/www\/html\/owncloud\/apps\/user_ldap\/group_ldap.php#561","level":3,"time":"2015-01-20T17:32:12+00:00"}

@gig13

sbelov1 avatar Jan 20 '15 21:01 sbelov1

@blizzz

karlitschek avatar Jan 21 '15 15:01 karlitschek

Updating the post with an exact php version:

PHP 5.4.34 (cli) (built: Oct 16 2014 10:19:38) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies

sbelov1 avatar Jan 21 '15 15:01 sbelov1

@sbelov1 what are the reproduction steps? What is the LDAP config?

Hint: https://raw.githubusercontent.com/owncloud/core/master/issue_template.md

blizzz avatar Jan 23 '15 11:01 blizzz

@blizzz I believe its the same user we were working with here: https://github.com/owncloud/core/issues/12118

Reproduction steps are as follows:

  1. Select Domain Users group only from the Group Filter
  2. Select Domain Users group from the User Filter Result: 2 users are shown Expected Result: ~200 users

sbelov1 avatar Jan 23 '15 17:01 sbelov1

@blizzz oh yes, and we have requested for LDAP config. I'll update once we get it back from customer.

sbelov1 avatar Jan 26 '15 14:01 sbelov1

ok, in the meantime, the missing users have "Domain Users" assigned as their primary group?

blizzz avatar Jan 26 '15 16:01 blizzz

@blizzz I believe so, yes. Looks like something we've already resolved, didn't we?

sbelov1 avatar Jan 26 '15 16:01 sbelov1

i am not aware, just that rework of primary group handling is still on my list (but for other reasons). And unfortunately everything works with my test AD.

blizzz avatar Jan 26 '15 16:01 blizzz

@blizzz would it be easier jumping on a quick call with customer? They've been having this issue for awhile now. It could be something specific to their environment as I'm not having this type of issue with anyone else.

sbelov1 avatar Jan 26 '15 16:01 sbelov1

Not really, at least not that alone. I would provide a patch to gather some debug output instead.

blizzz avatar Jan 27 '15 16:01 blizzz

@blizzz sounds good. Should I expect the patch now or do we have to wait for the LDAP config output from customer first?

sbelov1 avatar Jan 27 '15 16:01 sbelov1

@sbelov1 I'd like to LDAP have a look on the config first.

blizzz avatar Jan 27 '15 16:01 blizzz

@blizzz please check your email for the output.

sbelov1 avatar Jan 27 '15 21:01 sbelov1

@sbelov1: now i remember… the issue here is that the user filter restricts login to a "standard" group membership, but does not take primary groups into account. We sought to fix this with https://github.com/owncloud/core/pull/12233

blizzz avatar Jan 28 '15 09:01 blizzz

I follow up there, stay tuned.

blizzz avatar Jan 28 '15 09:01 blizzz

Oh, and for a manual workaround: currently there is no group limitation in user or login filter. To make this work with primary groups do as follow:

Change User Filter from

(&(|(objectclass=organizationalPerson)(objectclass=person)(objectclass=top)(objectclass=user)))

To

(&(|(objectclass=organizationalPerson)(objectclass=person)(objectclass=top)(objectclass=user))(|(memberof=CN=Domain Users,…)(primaryGroupID=513)))

and Login filter from

(&(&(|(objectclass=organizationalPerson)(objectclass=person)(objectclass=top)(objectclass=user)))(|(sAMAccountName=%uid))) 

To

(&((&(|(objectclass=organizationalPerson)(objectclass=person)(objectclass=top)(objectclass=user))(|(memberof=CN=Domain Users,…)(primaryGroupID=513))))(sAMAccountName=%uid))

In both cases you must insert the whole DN of the domain users group in the memberof= pair.

The primaryGroupID should be 513 for Domain Users. Otherwise you can get details of a user's domain group using this script: https://gist.github.com/blizzz/101e17cdc1d399031b50#file-primgrtest-php

Example usage and output:

$ sudo -u www-data ./primGrTest.php "cn=tara gilbert,ou=vampires,dc=madder,dc=owncloud,dc=bzoc" s01
User Primary Group ID is: 513
The DN of the domain is: dc=madder,dc=owncloud,dc=bzoc
The SID of the domain is: S-1-5-21-249921958-728525901-1594176202
The object SID should be: S-1-5-21-249921958-728525901-1594176202-513
VERY GOOD: The group DN is: cn=domain users,cn=users,dc=madder,dc=owncloud,dc=bzoc

It should not be necessary in this case though.

blizzz avatar Jan 28 '15 10:01 blizzz

OK, i think i have a fix here: https://github.com/owncloud/core/pull/13740 (mind: it is against master)

blizzz avatar Jan 28 '15 15:01 blizzz

@blizzz sounds good. Please let me know the instructions for applying it once its all set.

sbelov1 avatar Jan 28 '15 15:01 sbelov1

@sbelov1 here is the corresponding PR for stable7: https://github.com/owncloud/core/pull/13742

You can get a diff here https://github.com/owncloud/core/pull/13742.diff, save it and apply it using patch against 7.0.4 (worked for me):

$ patch -p1 < 13742.diff

blizzz avatar Jan 28 '15 16:01 blizzz

@blizzz this patch wouldn't affect any changes to the database or anything, right? Just a php code? Just wanted to make sure its safe to run as customer is on a production environment.

sbelov1 avatar Jan 28 '15 17:01 sbelov1