From 2ea7e1092336558809fc790c05adc6060e66973b Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Mon, 10 Jul 2017 19:43:49 +0100 Subject: [PATCH] Set ldap to not follow referrals by default Added LDAP_FOLLOW_REFERRALS .env option to override. Fixes #317 --- app/Services/LdapService.php | 2 ++ config/services.php | 1 + 2 files changed, 3 insertions(+) diff --git a/app/Services/LdapService.php b/app/Services/LdapService.php index 71dc9c0e1..598efc19d 100644 --- a/app/Services/LdapService.php +++ b/app/Services/LdapService.php @@ -42,6 +42,8 @@ class LdapService $userFilter = $this->buildFilter($this->config['user_filter'], ['user' => $userName]); $baseDn = $this->config['base_dn']; $emailAttr = $this->config['email_attribute']; + $followReferrals = $this->config['follow_referrals'] ? 1 : 0; + $this->ldap->setOption($ldapConnection, LDAP_OPT_REFERRALS, $followReferrals); $users = $this->ldap->searchAndGetEntries($ldapConnection, $baseDn, $userFilter, ['cn', 'uid', 'dn', $emailAttr]); if ($users['count'] === 0) return null; diff --git a/config/services.php b/config/services.php index 99022e5f2..b4959c724 100644 --- a/config/services.php +++ b/config/services.php @@ -80,6 +80,7 @@ return [ 'user_filter' => env('LDAP_USER_FILTER', '(&(uid=${user}))'), 'version' => env('LDAP_VERSION', false), 'email_attribute' => env('LDAP_EMAIL_ATTRIBUTE', 'mail'), + 'follow_referrals' => env('LDAP_FOLLOW_REFERRALS', false), ] ];