server icon indicating copy to clipboard operation
server copied to clipboard

LDAP entries with DN > 255 characters are unsupported

Open KB7777 opened this issue 10 years ago • 50 comments

Steps to reproduce

  1. Click at the Users page 2. 3.

Expected behaviour

Showing users at Users page

Actual behaviour

There is no users at Users page:

2016-11-17 13_25_35

Additional info: When I click at any group usrers are showing. When I disable LDAP plugin users are showing. But, sometimes it load only few records from LDAP.

The users from AD can log in with no problems. At least the few ones which I tested recently. I have over 1500 users at my OU.

Server configuration

Operating system: fully patched CentOS Linux release 7.2.1511 (Core)

Web server: Name : httpd Arch : x86_64 Version : 2.4.6 Release : 40.el7.centos.4

Database: Name : MariaDB-server Arch : x86_64 Version : 10.1.19 Release : 1.el7.centos

PHP version: Name : php55 Arch : x86_64 Version : 2.0 Release : 1.el7

Nextcloud version: (see Nextcloud admin page) 10.0.1 (stable)

Updated from an older Nextcloud/ownCloud or fresh install: Fresh install

Where did you install Nextcloud from: downloaded tar.gz from Nextcloud portal

List of activated apps: Enabled:

  • admin_audit: 1.0.0
  • dav: 1.0.1
  • federatedfilesharing: 1.0.1
  • files: 1.5.2
  • files_pdfviewer: 0.8.1
  • files_versions: 1.3.0
  • firstrunwizard: 1.1
  • notifications: 0.3.0
  • password_policy: 1.0.0
  • provisioning_api: 1.0.0
  • serverinfo: 1.1.1
  • theming: 1.0.1
  • updatenotification: 1.0.1
  • user_ldap: 1.0.1
  • workflowengine: 1.0.1

Disabled:

  • activity
  • comments
  • encryption
  • external
  • federation
  • files_accesscontrol
  • files_automatedtagging
  • files_external
  • files_retention
  • files_sharing
  • files_texteditor
  • files_trashbin
  • files_videoplayer
  • gallery
  • survey_client
  • systemtags
  • templateeditor
  • user_external
  • user_saml

The content of config/config.php: { "system": { "instanceid": "ocmvtc6rlvl3", "passwordsalt": "REMOVED SENSITIVE VALUE", "secret": "REMOVED SENSITIVE VALUE", "trusted_domains": [ "REMOVED SENSITIVE VALUE", "REMOVED SENSITIVE VALUE" ], "datadirectory": "/var/www/html/nextcloud/data", "overwrite.cli.url": "http://REMOVED SENSITIVE VALUE/nextcloud", "dbtype": "mysql", "version": "9.1.1.5", "dbname": "nextcloud", "dbhost": "localhost", "dbport": "", "dbtableprefix": "oc_", "dbuser": "REMOVED SENSITIVE VALUE", "dbpassword": "REMOVED SENSITIVE VALUE", "logtimezone": "UTC", "installed": true, "appstore.experimental.enabled": true, "loglevel": 0, "mail_smtpmode": "smtp", "mail_from_address": "nextcloud", "mail_domain": "REMOVED SENSITIVE VALUE", "mail_smtphost": "REMOVED SENSITIVE VALUE", "mail_smtpport": "25", "htaccess.RewriteBase": "/nextcloud", "knowledgebaseenabled": false, "enable_avatars": false, "allow_user_to_change_display_name": false, "enable_previews": false, "ldapIgnoreNamingRules": false, "ldapProviderFactory": "\OCA\User_LDAP\LDAPProviderFactory" "memcache.local": "\OC\Memcache\APCu" } }

Are you using external storage, if yes which one: local/smb/sftp/... No.

Are you using encryption: yes/no No.

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/... Active Directory.

LDAP configuration (delete this part if not used)

LDAP: +-------------------------------+----------------------------------------------------------------------+ | Configuration | | +-------------------------------+----------------------------------------------------------------------+ | hasMemberOfFilterSupport | 1 | | hasPagedResultSupport | | | homeFolderNamingRule | | | lastJpegPhotoLookup | 0 | | ldapAgentName | cn=app_nextcloud,ou=services,ou=Accounts,dc=REMOVED SENSITIVE VALUE,dc=com,dc=pl | | ldapAgentPassword | *** | | ldapAttributesForGroupSearch | | | ldapAttributesForUserSearch | | | ldapBackupHost | | | ldapBackupPort | | | ldapBase | ou=REMOVED SENSITIVE VALUE,ou=Accounts,dc=REMOVED SENSITIVE VALUE,dc=com,dc=pl | | ldapBaseGroups | ou=REMOVED SENSITIVE VALUE,ou=Accounts,dc=REMOVED SENSITIVE VALUE,dc=com,dc=pl | | ldapBaseUsers | ou=REMOVED SENSITIVE VALUE,ou=Accounts,dc=REMOVED SENSITIVE VALUE,dc=com,dc=pl | | ldapCacheTTL | 600 | | ldapConfigurationActive | 1 | | ldapDynamicGroupMemberURL | | | ldapEmailAttribute | mail | | ldapExperiencedAdmin | 0 | | ldapExpertUUIDGroupAttr | | | ldapExpertUUIDUserAttr | | | ldapExpertUsernameAttr | | | ldapGroupDisplayName | cn | | ldapGroupFilter | | | ldapGroupFilterGroups | | | ldapGroupFilterMode | 0 | | ldapGroupFilterObjectclass | | | ldapGroupMemberAssocAttr | uniqueMember | | ldapHost | REMOVED SENSITIVE VALUE | | ldapIgnoreNamingRules | | | ldapLoginFilter | (&(&(|(objectclass=person)))(samaccountname=%uid)) | | ldapLoginFilterAttributes | | | ldapLoginFilterEmail | 0 | | ldapLoginFilterMode | 0 | | ldapLoginFilterUsername | 1 | | ldapNestedGroups | 0 | | ldapOverrideMainServer | | | ldapPagingSize | 0 | | ldapPort | 389 | | ldapQuotaAttribute | | | ldapQuotaDefault | 5 GB | | ldapTLS | 0 | | ldapUserDisplayName | displayname | | ldapUserDisplayName2 | | | ldapUserFilter | (&(|(objectclass=person))) | | ldapUserFilterGroups | | | ldapUserFilterMode | 1 | | ldapUserFilterObjectclass | person | | ldapUuidGroupAttribute | auto | | ldapUuidUserAttribute | auto | | turnOffCertCheck | 1 | | useMemberOfToDetectMembership | 0 | +-------------------------------+----------------------------------------------------------------------+

Client configuration

Browser: Last Chrome, last Firefox, IE11

Operating system: Windows 7 x64.

Logs

Web server error log

[Mon Nov 21 13:20:13.149953 2016] [:error] [pid 15131] [client 10.151.40.57:17459] PHP Fatal error: Call to a member function composeAndStoreDisplayName() on a non-object in /var/www/html/nextcloud/apps/user_ldap/lib/Access.php on line 552

Nextcloud log (data/nextcloud.log)

{"reqId":"WDLme7NW3PMD4XfybYQpegAAAAQ","remoteAddr":"10.151.40.57","app":"PHP","message":"Call to a member function composeAndStoreDisplayName() on a non-object at /var/www/html/nextcloud/apps/user_ldap/lib/Access.php#552","level":3,"time":"2016-11-21T12:20:13+00:00","method":"GET","url":"/nextcloud/settings/users/users?offset=0&limit=50&gid=&pattern=","user":"admin"}

KB7777 avatar Nov 21 '16 12:11 KB7777

https://github.com/nextcloud/server/blob/813f0a0f40dd42b28cd35d91616f3f87ef400861/apps/user_ldap/lib/User/Manager.php#L220-L220 <- this could return null and cause the above error.

We should make this more resistant against such errors - @blizzz

MorrisJobke avatar Nov 21 '16 13:11 MorrisJobke

Another info -- if OU contains less accounts the page is showing up with no problems. Sometimes, if OU contains more accounts the page is showing not all users. if OU contains many more accounts the problem is like I discribed at first post.

KB7777 avatar Nov 21 '16 13:11 KB7777

@MorrisJobke indeed, and I agree it needs some checking. Nevertheless to understand the issue (and handle it more properly), I am interested why null is even returned there. It is supposed to come directly from LDAP.

@KB7777 perhaps it is related to one (or more) faulty records. Could you switch to debug level logging, retry and provide the resulting logs? Hoping to find more answers there.

blizzz avatar Nov 29 '16 22:11 blizzz

@blizzz I switched to debug mode and with big OU (2k users) I had 4 errors like: Debug user_ldap The ldap user manager returned null for 0B46xxxx-xxxx-43B2-xxxx-4B659078xxx 2016-11-30T13:33:31+01:00 admin

I spotted what is that object (normal user) and which OU contains it. Later I set that OU only at Nextcloud settings and I had more accounts with errors like "returned null for" :(

Every account is fine, users are working normally. Very strange.

KB7777 avatar Nov 30 '16 12:11 KB7777

@KB7777

The message occurs when a list of users from LDAP is received and some information is stored in Nextcloud (displayname, email, avatar, etc. if applicable). However this message indicates an issue with some of the records: a user object cannot be instantiated.

It's a good question why this happens, since we just got it from LDAP. Could you check the records for reported UUIDs on LDAP? Maybe something is unusual about them?

Could you also the check the oc_ldap_user_mappings table in the database? Are they entries for the reported failing UUIDs? How do they look like?

Can the users with the reported UUIDs log in?

Otherwise, nothing else interessting in the log?

blizzz avatar Dec 01 '16 13:12 blizzz

I am still invastigating, but is it possible the problem is caused by too long OU path? And polish characters-set at OU names?

KB7777 avatar Dec 05 '16 12:12 KB7777

I am still invastigating, but is it possible the problem is caused by too long OU path?

Sounds unlikely… but how much is "too long"?

And polish characters-set at OU names?

Once upon a time I tested it successfully with Persian, so Polish characters should be fine, too.

One issue that could arise is when creating a username out of an attribute that contains special characters and transliteration is not possible. This, however, would just make affected users be skipped.

blizzz avatar Dec 05 '16 17:12 blizzz

Hello @blizzz

I checked this problem with fresh NC11 and php7.1 instance and.. there is no problem :)

So, it could be NC10.0.1 bug, but IMO that was a problem with my installation. Maybe after upgrading php54 -> php55. I had a problem with upgrading to 10.0.2 -- https://help.nextcloud.com/t/10-0-1-10-0-2-php-problem/6152.

No, listing users works fine. I have another problem with ldap listings, but I think I will write another issue post :)

Regards.

KB7777 avatar Dec 19 '16 12:12 KB7777

Thanks for getting back and keeping us up to date. Sure, shoot the other issue!

blizzz avatar Dec 19 '16 13:12 blizzz

Hello again @blizzz !

I just discovered what is the cause of wrong listing users from ldap, so I reopen the issue. APCU! :)

with 'memcache.local' => '\OC\Memcache\APCu', there is no users listed. Without it the users are shown.

Log from debug from NC11 (x at GUID are mine edit):

	OC\User\NoUserException: xxxxxxxx-06EB-4460-B7D9-xxxxxxxxxxxx is not a valid user anymore
/var/www/html/nextcloud/lib/private/User/User.php - line 261: OCA\User_LDAP\User_LDAP->getHome('xxxxxxxx-06EB-4...')
/var/www/html/nextcloud/settings/Controller/UsersController.php - line 205: OC\User\User->getHome()
/var/www/html/nextcloud/settings/Controller/UsersController.php - line 266: OC\Settings\Controller\UsersController->formatUserForIndex(Object(OC\User\User))
[internal function] OC\Settings\Controller\UsersController->index(0, 50, '', '', '')
/var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 160: call_user_func_array(Array, Array)
/var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 90: OC\AppFramework\Http\Dispatcher->executeController(Object(OC\Settings\Controller\UsersController), 'index')
/var/www/html/nextcloud/lib/private/AppFramework/App.php - line 114: OC\AppFramework\Http\Dispatcher->dispatch(Object(OC\Settings\Controller\UsersController), 'index')
/var/www/html/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php - line 47: OC\AppFramework\App main('OC\\Settings\\Con...', 'index', Object(OC\AppFramework\DependencyInjection\DIContainer), Array)
[internal function] OC\AppFramework\Routing\RouteActionHandler->__invoke(Array)
/var/www/html/nextcloud/lib/private/Route/Router.php - line 299: call_user_func(Object(OC\AppFramework\Routing\RouteActionHandler), Array)
/var/www/html/nextcloud/lib/base.php - line 1010: OC\Route\Router->match('/settings/users...')
/var/www/html/nextcloud/index.php - line 40: OC handleRequest()
{main}

Regards.

KB7777 avatar Dec 29 '16 11:12 KB7777

~~@KB7777 is your LDAP behaving funny, or being behind a strange load balancer or proxy or anything like this?~~ never mind.

blizzz avatar Dec 29 '16 15:12 blizzz

@KB7777 do you get the same effect over command line?

./occ ldap:search "" 

(as web user)

blizzz avatar Dec 29 '16 16:12 blizzz

@blizzz

With APCU and without -- listed only 15 accounts. Alphabetically :)

KB7777 avatar Jan 03 '17 12:01 KB7777

@KB7777 15 is the default, you can specify a different limit using --limit=42 or also set a different offset, for instance. ./occ ldap:search --help shows you all the options.

Can you verify that APCu is enabled for command line? Typically it isn't and needs a config switch on PHP side.

blizzz avatar Jan 04 '17 09:01 blizzz

@blizzz

ldap:search works fine:

[root@nc11 nextcloud]# sudo -u apache ./occ ldap:search --limit=10000 ""  |wc -l
1952

But, some users are shown like FirstName LastName GUID but some like GUID only. Log shows No DN found for xxxxxx-3B1B-4647-B152-xxxxxxxxx.

Can you verify that APCu is enabled for command line?

How can I check this?

KB7777 avatar Jan 04 '17 09:01 KB7777

Check for apc.enable_cli=1 in your PHP config. This depends on your distribution, on an arch based one you would put it to /etc/php/conf.d/apcu.ini.

blizzz avatar Jan 04 '17 16:01 blizzz

[root@nc11 ~]# grep apc.enable_cli /etc/php.d/40-apcu.ini
;apc.enable_cli=0

When I change it to apc.enable_cli=1 and restarted httpd effect is the same. Some users are shown only with GUID.

KB7777 avatar Jan 05 '17 08:01 KB7777

@KB7777 can you verify that the GUID-only users have the displayname attribute set? You could find out the DN by looking into the oc_ldap_user_mapping table in the database.

blizzz avatar Jan 05 '17 09:01 blizzz

@blizzz Yes, they have.

But -- the column ldap_dn has varchar(255) and some Distinguished Names of my users has more than 255 characters.

KB7777 avatar Jan 12 '17 09:01 KB7777

@KB7777 and only those are affected?

blizzz avatar Jan 16 '17 13:01 blizzz