LDAP/AD Authnetication : 500 error on ajax request

Basic information

Nextcloud version (eg, 20.0.5): 20.0.7.1
Operating system and version (eg, Ubuntu 20.04): Debian Buster (10)
Apache or nginx version (eg, Apache 2.4.25): nginx/1.14.2
PHP version (eg, 7.4): ** PHP Version 7.3.19-1~deb10u1**

The issue you are facing:

When try to configure LDAP account : receive 500 error on each ajax action.

Is this the first time you’ve seen this error? Y:

Steps to replicate it:

  1. Setup iRedMail server on a new Debian 10
  2. Create some domin and user
  3. Install phpldap admin to check user access
  4. Try to setup with localhost or 127.0.0.1 : wizard send 500 error, add a new config same etc
  5. Looking at php log error

The output of your Nextcloud log in Admin > Logging:


(empty)

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

<?php
$CONFIG = array (
  'instanceid' => 'xxxxxxxxxxxxxx',
  'passwordsalt' => 'xxx/xx/xxxx',
  'secret' => 'xxxxx/xxxxx',
  'trusted_domains' => 
  array (
    0 => 'nuage.example.org',
  ),
  'datadirectory' => '/var/data',
  'dbtype' => 'mysql',
  'version' => '20.0.7.1',
  'overwrite.cli.url' => 'https://nuage.example.org',
  'dbname' => 'bdd_nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'bdd_nextcloud',
  'dbpassword' => 'xxxxxxxxxxxxxxxx',
  'installed' => true,
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'memcache.local' => '\OC\Memcache\APCu',
);

The output of your Apache/nginx/system log in /var/log/____:

# tail /var/log/php-error.log 
#0 {main}
  thrown in /var/www/apps/user_ldap/ajax/getConfiguration.php on line 30
[07-Feb-2021 19:18:41 GMT] PHP Fatal error:  Uncaught Error: Class 'OC_JSON' not found in /var/www/apps/user_ldap/ajax/wizard.php:33
Stack trace:
#0 {main}
  thrown in /var/www/apps/user_ldap/ajax/wizard.php on line 33
[07-Feb-2021 19:18:53 GMT] PHP Fatal error:  Uncaught Error: Class 'OC_JSON' not found in /var/www/apps/user_ldap/ajax/getNewServerConfigPrefix.php:28
Stack trace:
#0 {main}
  thrown in /var/www/apps/user_ldap/ajax/getNewServerConfigPrefix.php on line 28

php-json is here (see phpinfo (partial))

Capture d’écran du 2021-02-07 20-12-17

OK,

Adding require_once __DIR__ . '/../../../lib/base.php'; at all ajax/*.php seems to fix the issue.

I report on github after testing more.

For the record, as the PR in the thread suggest, to solve this I had to add this line on my nginx configuration (in the location php section)

rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy) /index.php$request_uri;
1 Like

Yes it’s in https://docs.nextcloud.com/server/19/admin_manual/installation/nginx.html
:slight_smile:

And in https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html now