AD server failure, now can't get logged in

Nextcloud version : 15.0.4.0
Operating system and version : Ubuntu 18.04
Apache or nginx version : nginx/1.14.0
PHP version : php-7.2

The issue you are facing:
My main domain controller (samba4) crashed. I have a backup domain controller (also samba4). I checked to ensure that there are no hardcoded references to the old server in either the database or the config file, DNS is pointing at the correct new server, but I get “Connection to LDAP server could not be established” in the log from getConnectionResource in /opt/nextcloud/apps/user_ldap/lib/Access.php. Where is this function pulling the name of the LDAP provider from?

(I checked that it’s not in the database by doing a pg_dump on the database and grepping for the old server’s DNS name.)

Also note that the GUID listed is the valid GUID of the user which is trying to login to Nextcloud, according to ADSI Edit browsing of my domain controller.

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

Steps to replicate it:

  1. On my server, I attempt to log in via the web interface
  2. Web interface shows an internal server error

The output of your Nextcloud log in Admin > Logging:

{
  "reqId": "XXXX",
  "level": 3,
  "time": "2019-03-07T06:33:28+00:00",
  "remoteAddr": "192.168.1.214",
  "user": "975F6760-0B78-4F08-84E1-5209C49B38FE",
  "app": "no app in context",
  "method": "GET",
  "url": "/index.php/apps/files/",
  "message": {
    "Exception": "OC\\ServerNotAvailableException",
    "Message": "Connection to LDAP server could not be established",
    "Code": 0,
    "Trace": [
      {
        "file": "/opt/nextcloud/apps/user_ldap/lib/Access.php",
        "line": 191,
        "function": "getConnectionResource",
        "class": "OCA\\User_LDAP\\Connection",
        "type": "->",
        "args": []
      },
      {
        "file": "/opt/nextcloud/apps/user_ldap/lib/Group_LDAP.php",
        "line": 484,
        "function": "readAttribute",
        "class": "OCA\\User_LDAP\\Access",
        "type": "->",
        "args": [
          "cn= ... STUFF DELETED ...",
          "primaryGroupID"
        ]
      },
      {
        "file": "/opt/nextcloud/apps/user_ldap/lib/Group_LDAP.php",
        "line": 508,
        "function": "getEntryGroupID",
        "class": "OCA\\User_LDAP\\Group_LDAP",
        "type": "->",
        "args": [
          "... STUFF DELETED ...",
          "primaryGroupID"
        ]
      },
      {
        "file": "/opt/nextcloud/apps/user_ldap/lib/Group_LDAP.php",
        "line": 589,
        "function": "getUserPrimaryGroupIDs",
        "class": "OCA\\User_LDAP\\Group_LDAP",
        "type": "->",
        "args": [
          "... STUFF DELETED ..."
        ]
      },
      {
        "file": "/opt/nextcloud/apps/user_ldap/lib/Group_LDAP.php",
        "line": 626,
        "function": "getUserPrimaryGroup",
        "class": "OCA\\User_LDAP\\Group_LDAP",
        "type": "->",
        "args": [
          "... STUFF DELETED ..."
        ]
      },
      {
        "file": "/opt/nextcloud/apps/user_ldap/lib/Group_Proxy.php",
        "line": 123,
        "function": "getUserGroups",
        "class": "OCA\\User_LDAP\\Group_LDAP",
        "type": "->",
        "args": [
          "975F6760-0B78-4F08-84E1-5209C49B38FE"
        ]
      },
      {
        "file": "/opt/nextcloud/lib/private/Group/Manager.php",
        "line": 281,
        "function": "getUserGroups",
        "class": "OCA\\User_LDAP\\Group_Proxy",
        "type": "->",
        "args": [
          "975F6760-0B78-4F08-84E1-5209C49B38FE"
        ]
      },
      {
        "file": "/opt/nextcloud/lib/private/Group/Manager.php",
        "line": 318,
        "function": "getUserIdGroups",
        "class": "OC\\Group\\Manager",
        "type": "->",
        "args": [
          "975F6760-0B78-4F08-84E1-5209C49B38FE"
        ]
      },
      {
        "file": "/opt/nextcloud/lib/private/Group/Manager.php",
        "line": 308,
        "function": "isInGroup",
        "class": "OC\\Group\\Manager",
        "type": "->",
        "args": [
          "975F6760-0B78-4F08-84E1-5209C49B38FE",
          "admin"
        ]
      },
      {
        "file": "/opt/nextcloud/apps/logreader/appinfo/app.php",
        "line": 6,
        "function": "isAdmin",
        "class": "OC\\Group\\Manager",
        "type": "->",
        "args": [
          "975F6760-0B78-4F08-84E1-5209C49B38FE"
        ]
      },
      {
        "file": "/opt/nextcloud/lib/private/legacy/app.php",
        "line": 261,
        "args": [
          "/opt/nextcloud/apps/logreader/appinfo/app.php"
        ],
        "function": "require_once"
      },
      {
        "file": "/opt/nextcloud/lib/private/legacy/app.php",
        "line": 154,
        "function": "requireAppFile",
        "class": "OC_App",
        "type": "::",
        "args": [
          "logreader"
        ]
      },
      {
        "file": "/opt/nextcloud/lib/private/legacy/app.php",
        "line": 127,
        "function": "loadApp",
        "class": "OC_App",
        "type": "::",
        "args": [
          "logreader"
        ]
      },
      {
        "file": "/opt/nextcloud/lib/base.php",
        "line": 972,
        "function": "loadApps",
        "class": "OC_App",
        "type": "::",
        "args": []
      },
      {
        "file": "/opt/nextcloud/index.php",
        "line": 42,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/opt/nextcloud/apps/user_ldap/lib/Connection.php",
    "Line": 204,
    "CustomMessage": "--"
  },
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15",
  "version": "15.0.4.0"
}

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

<?php
$CONFIG = array (
  'instanceid' => 'XXXX',
  'passwordsalt' => 'XXXX',
  'secret' => 'XXXX',
  'trusted_domains' => 
  array (
    0 => '192.168.1.22',
    1 => 'nextcloud.lan',
    2 => 'nextcloud.XXXX.com',
  ),
  'datadirectory' => '/mnt/nextcloud_files',
  'overwrite.cli.url' => 'http://192.168.1.22',
  'dbtype' => 'pgsql',
  'version' => '15.0.4.0',
  'installed' => true,
  'mail_from_address' => 'XXX',
  'mail_smtpmode' => 'smtp',
  'mail_domain' => 'XXX',
  'ldapIgnoreNamingRules' => false,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '465',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpname' => 'XXX@example.com',
  'mail_smtppassword' => 'XXXX',
  'forcessl' => true,
  'forceSSLforSubdomains' => true,
  'theme' => '',
  'maintenance' => false,
  'logfile' => '/mnt/nextcloud_files/nextcloud.log',
  'loglevel' => 2,
  'trashbin_retention_obligation' => 'auto',
  'dbname' => 'XXXX',
  'dbhost' => 'myserver.lan',
  'dbuser' => 'XXXX',
  'dbpassword' => 'XXXX',
  'htaccess.RewriteBase' => '/',
  'updater.release.channel' => 'stable',
  'updater.server.url' => 'https://updates.nextcloud.com/updater_server/',
  'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory',
);

Argh. It turns out I found another question that fixed this problem, and it was one I asked a few years ago. Nextcloud doesn’t support strong authentication in its ldap queries, and so you must disable it in your smb.conf on your domain controller (if you’re using samba) by putting “ldap server require strong auth = no” in the [global] section.