Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit cd24cfc

Browse files
committed
LDAP Driver: add a parameter for the users count cache TTL
1 parent 5c0a9b1 commit cd24cfc

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

core/src/plugins/auth.ldap/class.ldapAuthDriver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,10 +890,12 @@ public function fakeMemberOf($conn, $groupDN, $filterString, $atts, &$entry)
890890

891891
public function getCountFromCache()
892892
{
893+
$ttl = $this->getOption("LDAP_COUNT_CACHE_TTL");
894+
if(empty($ttl)) $ttl = 1;
893895
$fileName = "ldap.ser";
894896
if (file_exists($this->getPluginCacheDir() . DIRECTORY_SEPARATOR . $fileName)) {
895897
$fileContent = unserialize(file_get_contents($this->getPluginCacheDir() . DIRECTORY_SEPARATOR . $fileName));
896-
if (($fileContent) && ($fileContent["count"]) && ($fileContent["timestamp"]) && ((time() - $fileContent["timestamp"]) < 60 * 30)) {
898+
if (($fileContent) && ($fileContent["count"]) && ($fileContent["timestamp"]) && ((time() - $fileContent["timestamp"]) < 60 * 60 * $ttl)) {
897899
return $fileContent;
898900
}
899901
}

core/src/plugins/auth.ldap/manifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<param name="MAPPING_LDAP_PARAM" type="string" replicationGroup="MAPPING" label="CONF_MESSAGE[LDAP attribute]" description="CONF_MESSAGE[Name of the LDAP attribute to read]" mandatory="false"/>
2929
<param name="MAPPING_LOCAL_TYPE" type="select" replicationGroup="MAPPING" choices="plugin_param|Plugin Parameter,role_id|Role Id,group_path|Group Path,profile|Profile" label="CONF_MESSAGE[Mapping Type]" description="CONF_MESSAGE[Determine the type of mapping]" mandatory="false"/>
3030
<param name="MAPPING_LOCAL_PARAM" type="string" replicationGroup="MAPPING" label="CONF_MESSAGE[Plugin parameter]" description="CONF_MESSAGE[Name of the custom local parameter to set]" mandatory="false"/>
31+
<param type="integer" name="LDAP_COUNT_CACHE_TTL" label="CONF_MESSAGE[Cache User Count (hours)]" description="CONF_MESSAGE[Locally cache the total number of users during X hours. Can be handy for huge directories.]" mandatory="false" default="1"/>
3132
<param type="string" name="TEST_USER" label="CONF_MESSAGE[Test User]" description="CONF_MESSAGE[Use the Test Connexion button to check if this user is correctly found in your LDAP directory.]" mandatory="false"/>
3233
<param type="button" name="TEST_LDAP" choices="run_plugin_action:auth.ldap:testLDAPConnexion" label="CONF_MESSAGE[Test Connexion]" description="CONF_MESSAGE[Try to connect to LDAP]" mandatory="false"/>
3334
</server_settings>

0 commit comments

Comments
 (0)