Unable to log out

Support intro

I configured Nextcloud with SAML, but I used Active Directory and local users that were configured in Nextcloud itself.

I configured a logout URL in /lib/private/NavigationManger.php
// $logoutUrl = \OC_User::getLogoutUrl($this->urlGenerator);
$logoutUrl = ‘https://domain.de/nextcloud/logout.php’;
Because I didn’t know where the logout URL can be configured I just commented the first line out.

This is my logout.php
setcookie(‘MOD_AUTH_CAS_S’, null, -1, ‘/index.php/’);

setcookie('MOD_AUTH_CAS', null, -1, '/index.php/');
setcookie('oc_sessionPassphrase', null, -1, '/');
unset($_SESSION['xxxx']);   ###instanceid can be found in NextcloudDir/config/config.php
setcookie('xxx', null, -1, '/');
header('Location: https://domain.de/logout.php');

Nextcloud version: 18.0.4
Operating system and version: unknown (it’s a webmanaged server by Hetzner)
Apache or nginx version: unknown
PHP version: 7.4

The issue you are facing:
If I log in with SAML/SSO I can logout without problems and I see the login page. But when I log in as a non ldap user and I try to log out, the page redirects to:
and the following message is shown:

"User is already logged-in"

Is this the first time you’ve seen this error? N

Steps to replicate it:

  1. Setup SAML (in my case with Active Directory)
  2. Setup logout URL
  3. Create test user in Nextcloud
  4. Login as test user
  5. Logout as test user

The output of your Nextcloud log in Admin > Logging:

Nothing what has to do with this problem.

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

$CONFIG = array (
  'instanceid' => 'xxx',
  'passwordsalt' => 'xxx/kFWbVxuHRyLp9',
  'secret' => 'xxx/V7o4ZA25+UKfbcqoOlH14KWiVn4YtWmjGf',
  'trusted_domains' => 
  array (
    0 => 'xxx.de',
    1 => 'cloud.xxx.de',
  'datadirectory' => '/usr/www/users/xxx/nextcloud-data',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => 'http://xxx.de/nextcloud',
  'dbname' => 'nextclouddb',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'ncdbuser',
  'dbpassword' => 'xxx',
  'installed' => true,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'webmaster',
  'mail_domain' => 'xxx.de',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'localhost',
  'mail_smtpport' => '25',
  'mail_smtpname' => 'webmaster@xxx.de',
  'mail_smtppassword' => 'xxx',
  'default_language' => 'de',
  'default_locale' => 'de',
  'updater.release.channel' => 'stable',
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'remember_login_cookie_lifetime' => 60*60*24*15,
  'session_lifetime' => 60 * 60 * 1,
  'session_keepalive' => false,

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

No access because it's a managed webserver with no SSH access.