# How to prevent LDAP session timeouts?

**URL:** <https://help.nextcloud.com/t/how-to-prevent-ldap-session-timeouts/94094>\
**Category:** ℹ️ Support\
**Tags:** ldap\
**Created:** [October 5, 2020, 3:08pm UTC](https://help.nextcloud.com/t/how-to-prevent-ldap-session-timeouts/94094 "2020-10-05T15:08:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![neilrooney](https://help.nextcloud.com/user_avatar/help.nextcloud.com/neilrooney/32/27348_2.png) [@neilrooney](https://help.nextcloud.com/u/neilrooney)\
**Post date:** [October 5, 2020, 3:08pm UTC](https://help.nextcloud.com/t/how-to-prevent-ldap-session-timeouts/94094/1 "2020-10-05T15:08:24Z")

</div>

Hi all, hope everyone had a great conference this past weekend.

I have configured LDAP and am able to login, see groups, users etc, works great. I am however experiencing an issue where users are logged out of their session after 5 minutes. Is there a way to prevent this or at least extend the session time when logging in with LDAP.

We are currently using Okta LDAP interface with MFA. The interesting thing is, when signing in with MFA app with push notifications, after 5 mins Nextcloud will freeze and I will get new MFA push notifications. It’s as if Nextcloud is constantly re-authenticating.

Config.php below:

```
<?php
$CONFIG = array (
  'passwordsalt' => #Confidential#,
  'secret' => #Confidential#,
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => #Confidential#,
    2 => #Confidential#,
    3 => #Confidential#,
  ),
  'datadirectory' => '/mnt/ncdata',
  'dbtype' => 'pgsql',
  'version' => '20.0.0.9',
  'overwrite.cli.url' => #Confidential#,
  'dbname' => #Confidential#,
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => #Confidential#,
  'dbpassword' => #Confidential#,
  'installed' => true,
  'instanceid' => #Confidential#,
  'upgrade.disable-web' => 'true',
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'loglevel' => '2',
  'log.condition' =>
  array (
    'apps' =>
    array (
      0 => 'admin_audit',
    ),
  ),
  'mail_smtpmode' => 'smtp',
  'remember_login_cookie_lifetime' => '1800',
  'log_rotate_size' => '0',
  'trashbin_retention_obligation' => 'auto, 180',
  'versions_retention_obligation' => 'auto, 365',
  'simpleSignUpLink.shown' => false,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.5,
    'dbindex' => 0,
    'password' => #Confidential#,
  ),
  'logtimezone' => 'Europe/Berlin',
  'htaccess.RewriteBase' => '/',
  'share_folder' => '/Shared',
  'enable_previews' => true,
  'enabledPreviewProviders' =>
  array (
    11 => 'OC\\Preview\\PNG',
    12 => 'OC\\Preview\\JPEG',
    13 => 'OC\\Preview\\GIF',
    14 => 'OC\\Preview\\BMP',
    15 => 'OC\\Preview\\MarkDown',
    16 => 'OC\\Preview\\MP3',
    17 => 'OC\\Preview\\TXT',
    18 => 'OC\\Preview\\Movie',
  ),
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'maintenance' => false,
  'mail_from_address' => 'nextcloud',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => #Confidential#,
  'mail_smtpsecure' => 'tls',
  'mail_smtphost' => 'smtp-relay.gmail.com',
  'mail_smtpport' => '587',
);
```

---

<div class="post-metadata">

**Author:** ![neilrooney](https://help.nextcloud.com/user_avatar/help.nextcloud.com/neilrooney/32/27348_2.png) [@neilrooney](https://help.nextcloud.com/u/neilrooney)\
**Post date:** [October 5, 2020, 3:22pm UTC](https://help.nextcloud.com/t/how-to-prevent-ldap-session-timeouts/94094/2 "2020-10-05T15:22:42Z")

</div>

Looks like another user had exactly the same issue back in 2018.

> [@LDAP 2-FA auth: users logged out after 5 minutes/app passwords destroyed](https://help.nextcloud.com/t/ldap-2-fa-auth-users-logged-out-after-5-minutes-app-passwords-destroyed/38218):
>
> I am completely stumped here and not sure what would be causing this to happen other than a bug. I have a brand new NextCloud installation tied into FreeIPA using LDAP. All web users MUST have 2-FA enabled through FreeIPA and this works perfectly for OpenVPN, SSH, Drupal AND WordPress. Truth be told LDAP is working great for logins, password+OTP works well and users can get to their files. The only problem is that every 5 minutes users get logged out. This even happens to the mobile app if you l…

@hobbymaster001 did you ever find a fix for this problem?

---

<div class="post-metadata">

**Author:** ![anon71540698](https://help.nextcloud.com/letter_avatar/anon71540698/32/6_22734026db12803ebb3e059622ac3534.png) [@anon71540698](https://help.nextcloud.com/u/anon71540698)\
**Post date:** [October 5, 2020, 6:35pm UTC](https://help.nextcloud.com/t/how-to-prevent-ldap-session-timeouts/94094/3 "2020-10-05T18:35:39Z")

</div>

Have you checked this?

> [@SyncClient (Windows): reject app password / automatic logout after few minutes](https://help.nextcloud.com/t/syncclient-windows-reject-app-password-automatic-logout-after-few-minutes/65963/5):
>
> hi I encounter a similar problem. With desktop client, I was deconnect after 5 minutes. In file nextcloud/lib/private/User/Session.php, there is a check of token validity each 5 minutes in ligne 676 : /\*\* \* @param IToken $dbToken \* @param string $token \* @return boolean \*/ private function checkTokenCredentials(IToken $dbToken, $token) { // Check whether login credentials are still valid and the user was not disabled // This check is performed each 5 …

---

<div class="post-metadata">

**Author:** ![neilrooney](https://help.nextcloud.com/user_avatar/help.nextcloud.com/neilrooney/32/27348_2.png) [@neilrooney](https://help.nextcloud.com/u/neilrooney)\
**Post date:** [October 8, 2020, 7:52pm UTC](https://help.nextcloud.com/t/how-to-prevent-ldap-session-timeouts/94094/4 "2020-10-08T19:52:14Z")

</div>

This may actually work @anon71540698 but were we to off-board a user from the company, the login session would remain active until this time runs out. I guess then it would be impossible to use LDAP with MFA in this regard as the code is always new.

For now I have done the following:

1. Whitelisted the VM IP from the MFA requirement.
2. Enabled the MFA app from within Nextcloud.

Users can now login with their LDAP credentials but MFA is enabled on the Nextcloud side. It’s a workaround but does the job.

---

<div class="post-metadata">

**Author:** ![DevOps](https://help.nextcloud.com/user_avatar/help.nextcloud.com/devops/32/40299_2.png) [@DevOps](https://help.nextcloud.com/u/DevOps)\
**Post date:** [September 22, 2021, 3:00am UTC](https://help.nextcloud.com/t/how-to-prevent-ldap-session-timeouts/94094/6 "2021-09-22T03:00:20Z")

</div>

Looks like every 5 minutes the app is trying to validate the session using the same password entered before however because of TOTP the password is never the same again  
Is there a solution to this?

---

<div class="post-metadata">

**Author:** ![tuxick](https://help.nextcloud.com/user_avatar/help.nextcloud.com/tuxick/32/45892_2.png) [@tuxick](https://help.nextcloud.com/u/tuxick)\
**Post date:** [February 13, 2023, 12:31pm UTC](https://help.nextcloud.com/t/how-to-prevent-ldap-session-timeouts/94094/7 "2023-02-13T12:31:17Z")

</div>

I’m having the same problem with ldap via duoauthproxy.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 14, 2024, 3:54pm UTC](https://help.nextcloud.com/t/how-to-prevent-ldap-session-timeouts/94094/8 "2024-12-14T15:54:49Z")

</div>


