Update plugin.php
Explicit switch to LDAP 3 protocol, fix for YOURLS 1.7
This commit is contained in:
parent
8a619851e7
commit
c6d6c3a52c
@ -79,6 +79,7 @@ function ldapauth_is_valid_user( $value ) {
|
|||||||
// try to authenticate
|
// try to authenticate
|
||||||
$ldapConnection = ldap_connect(LDAPAUTH_HOST, LDAPAUTH_PORT);
|
$ldapConnection = ldap_connect(LDAPAUTH_HOST, LDAPAUTH_PORT);
|
||||||
if (!$ldapConnection) Die("Cannot connect to LDAP " . LDAPAUTH_HOST);
|
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'] );
|
$searchDn = ldap_search($ldapConnection, LDAPAUTH_BASE, LDAPAUTH_USERNAME_FIELD . "=" . $_REQUEST['username'] );
|
||||||
if (!$searchDn) return $value;
|
if (!$searchDn) return $value;
|
||||||
$searchResult = ldap_get_entries($ldapConnection, $searchDn);
|
$searchResult = ldap_get_entries($ldapConnection, $searchDn);
|
||||||
@ -93,6 +94,8 @@ function ldapauth_is_valid_user( $value ) {
|
|||||||
{
|
{
|
||||||
$username = $searchResult[0][LDAPAUTH_USERNAME_FIELD][0];
|
$username = $searchResult[0][LDAPAUTH_USERNAME_FIELD][0];
|
||||||
yourls_set_user($username);
|
yourls_set_user($username);
|
||||||
|
global $yourls_user_passwords;
|
||||||
|
$yourls_user_passwords[$username] = uniqid("",true);
|
||||||
$_SESSION['LDAPAUTH_AUTH_USER'] = $username;
|
$_SESSION['LDAPAUTH_AUTH_USER'] = $username;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user