From 7c1f6be5011e4422e7a9f11c9c576839ee28b0c4 Mon Sep 17 00:00:00 2001 From: Chris Hastie Date: Fri, 22 Jul 2016 10:43:03 +0100 Subject: [PATCH] No need to try checking for LDAPAUTH_USERNAME_FIELD without lowercasing. PHP manual confirms array index is always lower case --- plugin.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugin.php b/plugin.php index 6e19edd..ab0666a 100644 --- a/plugin.php +++ b/plugin.php @@ -148,11 +148,8 @@ function ldapauth_is_valid_user( $value ) { if (!$in_group) die('Not in admin group'); } - $username = $searchResult[0][LDAPAUTH_USERNAME_FIELD][0]; - if (empty($username)) { - // try with it lower cased - $username = $searchResult[0][strtolower(LDAPAUTH_USERNAME_FIELD)][0]; - } + // attribute index returned by ldap_get_entries is lowercased (http://php.net/manual/en/function.ldap-get-entries.php) + $username = $searchResult[0][strtolower(LDAPAUTH_USERNAME_FIELD)][0]; yourls_set_user($username); if (LDAPAUTH_ADD_NEW && !array_key_exists($username, $yourls_user_passwords)) {