LDAP user plugin stopped working after upgrade to Nextcloud version 19.0.1

Nextcloud version (eg, 18.0.2): 19.0.1
Operating system and version (eg, Ubuntu 20.04): Ubuntu 18.04
Apache or nginx version (eg, Apache 2.4.25): 2.4.29
PHP version (eg, 7.1): 7.2.24

The issue you are facing: LDAP user plugin crashing after upgrade to Nextcloud 19.0.1

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Try to log in with LDAP user

Or:

  1. Disable LDAP user plugin
  2. Login as local user
  3. Re-enable LDAP user plugin
  4. Open settings/users page

Or:

  1. Run “sudo -u www-data php occ user:list”

The output of your Nextcloud log in Admin > Logging:

[index] Error: TypeError: Return value of OCA\User_LDAP\PagedResults\Php54::getCookie() must be of the type string, null returned at <<closure>>

 0. /opt/nextcloud/apps/user_ldap/lib/LDAP.php line 89
    OCA\User_LDAP\PagedResults\Php54->getCookie(null)
 1. /opt/nextcloud/apps/user_ldap/lib/Access.php line 1183
    OCA\User_LDAP\LDAP->controlPagedResultResponse(null, false, null)
 2. /opt/nextcloud/apps/user_ldap/lib/Access.php line 1341
    OCA\User_LDAP\Access->processPagedSearchStatus(null, 1, 500, true, false)
 3. /opt/nextcloud/apps/user_ldap/lib/Access.php line 990
    OCA\User_LDAP\Access->search("uid=***REDACTED***", "ou=***REDACTED***", ["entryuuid","ns ... "], null, null)
 4. /opt/nextcloud/apps/user_ldap/lib/Access.php line 874
    OCA\User_LDAP\Access->searchUsers("uid=***REDACTED***", ["entryuuid","ns ... "], null, null)
 5. /opt/nextcloud/apps/user_ldap/lib/Access.php line 854
    OCA\User_LDAP\Access->fetchListOfUsers("uid=***REDACTED***", ["entryuuid","ns ... "])
 6. /opt/nextcloud/apps/user_ldap/lib/User_LDAP.php line 157
    OCA\User_LDAP\Access->fetchUsersByLoginName("*** sensitive parameter replaced ***", ["entryuuid","ns ... "])
 7. /opt/nextcloud/apps/user_ldap/lib/User_LDAP.php line 174
    OCA\User_LDAP\User_LDAP->getLDAPUserByLoginName("*** sensitive parameter replaced ***")
 8. <<closure>>
    OCA\User_LDAP\User_LDAP->checkPassword("*** sensitive parameters replaced ***")
 9. /opt/nextcloud/apps/user_ldap/lib/User_Proxy.php line 89
    call_user_func_array([OCA\User_LDAP\U ... "], ["*** sensitive  ... "])
10. /opt/nextcloud/apps/user_ldap/lib/Proxy.php line 167
    OCA\User_LDAP\User_Proxy->walkBackends("*** sensitive parameter replaced ***", "checkPassword", ["*** sensitive  ... "])
11. /opt/nextcloud/apps/user_ldap/lib/User_Proxy.php line 231
    OCA\User_LDAP\Proxy->handleRequest("*** sensitive parameter replaced ***", "checkPassword", ["*** sensitive  ... "])
12. /opt/nextcloud/lib/private/User/Manager.php line 225
    OCA\User_LDAP\User_Proxy->checkPassword("*** sensitive parameters replaced ***")
13. /opt/nextcloud/lib/private/User/Manager.php line 202
    OC\User\Manager->checkPasswordNoLogging("*** sensitive parameters replaced ***")
14. /opt/nextcloud/lib/private/User/Session.php line 755
    OC\User\Manager->checkPassword("*** sensitive parameters replaced ***")
15. /opt/nextcloud/lib/private/User/Session.php line 789
    OC\User\Session->checkTokenCredentials(OC\Authenticatio ... 3}, "*** sensitive parameter replaced ***")
16. /opt/nextcloud/lib/private/User/Session.php line 268
    OC\User\Session->validateToken("*** sensitive parameters replaced ***")
17. /opt/nextcloud/lib/private/User/Session.php line 243
    OC\User\Session->validateSession()
18. /opt/nextcloud/lib/private/User/Session.php line 280
    OC\User\Session->getUser()
19. /opt/nextcloud/lib/base.php line 991
    OC\User\Session->isLoggedIn()
20. /opt/nextcloud/index.php line 37
    OC::handleRequest()

GET /index.php/csrftoken
from 131.169.132.188 by c9a95f59-05ef-4a3c-8306-d8c09aa4057a at 2020-08-14T16:04:50+00:00
[PHP] Error: ldap_control_paged_result_response(): No server controls in result at /opt/nextcloud/apps/user_ldap/lib/PagedResults/Php54.php#49

GET /index.php/csrftoken
from 131.169.132.188 by c9a95f59-05ef-4a3c-8306-d8c09aa4057a at 2020-08-14T16:04:50+00:00

Or at the console:

# sudo -u www-data php occ user:list
An unhandled exception has been thrown:
TypeError: Return value of OCA\User_LDAP\PagedResults\Php54::getCookie() must be of the type string, null returned in /opt/nextcloud/apps/user_ldap/lib/PagedResults/Php54.php:64
Stack trace:
#0 /opt/nextcloud/apps/user_ldap/lib/LDAP.php(89): OCA\User_LDAP\PagedResults\Php54->getCookie(Resource id #1081)
#1 /opt/nextcloud/apps/user_ldap/lib/Access.php(1183): OCA\User_LDAP\LDAP->controlPagedResultResponse(Resource id #1081, false, NULL)
#2 /opt/nextcloud/apps/user_ldap/lib/Access.php(1341): OCA\User_LDAP\Access->processPagedSearchStatus(Resource id #1082, 117, 500, true, false)
#3 /opt/nextcloud/apps/user_ldap/lib/Access.php(990): OCA\User_LDAP\Access->search('(&(gidNumber=14...', 'ou=People,ou=rg...', Array, 500, 0)
#4 /opt/nextcloud/apps/user_ldap/lib/Access.php(874): OCA\User_LDAP\Access->searchUsers('(&(gidNumber=14...', Array, 500, 0)
#5 /opt/nextcloud/apps/user_ldap/lib/User_LDAP.php(276): OCA\User_LDAP\Access->fetchListOfUsers('(&(gidNumber=14...', Array, 500, 0)
#6 /opt/nextcloud/apps/user_ldap/lib/User_Proxy.php(176): OCA\User_LDAP\User_LDAP->getUsers('', 500, 0)
#7 /opt/nextcloud/lib/private/User/Manager.php(246): OCA\User_LDAP\User_Proxy->getUsers('', 500, 0)
#8 /opt/nextcloud/core/Command/User/ListCommand.php(85): OC\User\Manager->search('', 500, 0)
#9 /opt/nextcloud/3rdparty/symfony/console/Command/Command.php(255): OC\Core\Command\User\ListCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /opt/nextcloud/core/Command/Base.php(169): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /opt/nextcloud/3rdparty/symfony/console/Application.php(1012): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /opt/nextcloud/3rdparty/symfony/console/Application.php(272): Symfony\Component\Console\Application->doRunCommand(Object(OC\Core\Command\User\ListCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /opt/nextcloud/3rdparty/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /opt/nextcloud/lib/private/Console/Application.php(215): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /opt/nextcloud/console.php(100): OC\Console\Application->run()
#16 /opt/nextcloud/occ(11): require_once('/opt/nextcloud/...')

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => '***REDACTED***',
  'passwordsalt' => '***REDACTED***',
  'secret' => '***REDACTED***,
  'trusted_domains' => 
  array (
    0 => '***REDACTED***',
  ),
  'datadirectory' => '/opt/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '19.0.1.1',
  'overwrite.cli.url' => '***REDACTED***',
  'dbname' => '***REDACTED***',
  'dbhost' => '***REDACTED***',
  'dbport' => '',
  'dbtableprefix' => '***REDACTED***',
  'mysql.utf8mb4' => true,
  'dbuser' => '***REDACTED***',
  'dbpassword' => '***REDACTED***',
  'installed' => true,
  'app_install_overwrite' => 
  array (
    0 => 'user_pwauth',
    1 => 'mood',
  ),
  'maintenance' => false,
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'mail_from_address' => 'root',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => '***REDACTED***',
  'mail_smtphost' => '***REDACTED***',
  'mail_smtpport' => '25',
  'theme' => '',
  'loglevel' => 2,
  'updater.secret' => '***REDACTED***',
);

The output of your Apache/nginx/system log in /var/log/____:
(nothing relevant there)

Same thing here. Disabled via:

sudo -u apache php occ app:disable user_ldap

Not sure why my Nextcloud client sync still works…

nextcloud.log excerpt

{“reqId”:“PphDJqVqsC4lCAhBhOvQ”,“level”:2,“time”:“2020-08-15T06:22:13+00:00”,“remoteAddr”:"",“user”:"–",“app”:“user_ldap”,“method”:"",“url”:"–",“message”:“Configuration Error (prefix s01): login filter does not contain %uid place holder.”,“userAgent”:"–",“version”:“19.0.1.1”}

I was able to fix it by upgrading php 7.2 to 7.4. There should be at least a clear error message that the LDAP user plugin does not work with php 7.2…