diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-08-19 16:26:07 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-08-19 16:26:07 -0700 |
commit | be2ac5f1c936f17e2879636ac9e913f0e4c4ad02 (patch) | |
tree | ec9d553677c62cf729c8405cc0820e275dc925d9 /app/Auth | |
parent | 4b1bb1e83b0e76dcaf00a45d3a447fc020dbd5c0 (diff) |
Add multiple LDAP binding type
Diffstat (limited to 'app/Auth')
-rw-r--r-- | app/Auth/Ldap.php | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/Auth/Ldap.php b/app/Auth/Ldap.php index bb17653d..97d4d0e3 100644 --- a/app/Auth/Ldap.php +++ b/app/Auth/Ldap.php @@ -96,8 +96,21 @@ class Ldap extends Base ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); - if (! @ldap_bind($ldap, LDAP_USERNAME, LDAP_PASSWORD)) { - die('Unable to bind to the LDAP server: "'.LDAP_SERVER.'"'); + if (LDAP_BIND_TYPE === 'user') { + $ldap_username = sprintf(LDAP_USERNAME, $username); + $ldap_password = $password; + } + else if (LDAP_BIND_TYPE === 'proxy') { + $ldap_username = LDAP_USERNAME; + $ldap_password = LDAP_PASSWORD; + } + else { + $ldap_username = null; + $ldap_password = null; + } + + if (! @ldap_bind($ldap, $ldap_username, $ldap_password)) { + return false; } $sr = @ldap_search($ldap, LDAP_ACCOUNT_BASE, sprintf(LDAP_USER_PATTERN, $username), array(LDAP_ACCOUNT_FULLNAME, LDAP_ACCOUNT_EMAIL)); |