From c6d6c3a52c4088af3945fc7f4b7b1a6f1b20d66e Mon Sep 17 00:00:00 2001 From: K3A Date: Tue, 28 Jan 2014 13:08:39 +0100 Subject: [PATCH] Update plugin.php Explicit switch to LDAP 3 protocol, fix for YOURLS 1.7 --- plugin.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin.php b/plugin.php index f3ba401..444cd52 100644 --- a/plugin.php +++ b/plugin.php @@ -79,6 +79,7 @@ function ldapauth_is_valid_user( $value ) { // try to authenticate $ldapConnection = ldap_connect(LDAPAUTH_HOST, LDAPAUTH_PORT); if (!$ldapConnection) Die("Cannot connect to LDAP " . LDAPAUTH_HOST); + ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3); $searchDn = ldap_search($ldapConnection, LDAPAUTH_BASE, LDAPAUTH_USERNAME_FIELD . "=" . $_REQUEST['username'] ); if (!$searchDn) return $value; $searchResult = ldap_get_entries($ldapConnection, $searchDn); @@ -93,6 +94,8 @@ function ldapauth_is_valid_user( $value ) { { $username = $searchResult[0][LDAPAUTH_USERNAME_FIELD][0]; yourls_set_user($username); + global $yourls_user_passwords; + $yourls_user_passwords[$username] = uniqid("",true); $_SESSION['LDAPAUTH_AUTH_USER'] = $username; return true; }