LDAP - Force protocol LDAPv3
On Linux, php-ldap seems to rely on a library which still uses deprecated LDAPv2 as default version, causing authentication issues. See: https://stackoverflow.com/a/48238224/1484919
This commit is contained in:
parent
a69cfe0dd2
commit
8694e8411b
1 changed files with 11 additions and 3 deletions
|
@ -204,12 +204,20 @@ public function checkCredentialsFromLocalConfig($login, $password) {
|
||||||
*/
|
*/
|
||||||
public function checkCredentialsFromLdap($login, $password, $connect = null, $bind = null)
|
public function checkCredentialsFromLdap($login, $password, $connect = null, $bind = null)
|
||||||
{
|
{
|
||||||
$connect = $connect ?? function($host) { return ldap_connect($host); };
|
$connect = $connect ?? function($host) {
|
||||||
$bind = $bind ?? function($handle, $dn, $password) { return ldap_bind($handle, $dn, $password); };
|
$resource = ldap_connect($host);
|
||||||
|
|
||||||
|
ldap_set_option($resource, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||||
|
|
||||||
|
return $resource;
|
||||||
|
};
|
||||||
|
$bind = $bind ?? function($handle, $dn, $password) {
|
||||||
|
return ldap_bind($handle, $dn, $password);
|
||||||
|
};
|
||||||
|
|
||||||
return $bind(
|
return $bind(
|
||||||
$connect($this->configManager->get('ldap.host')),
|
$connect($this->configManager->get('ldap.host')),
|
||||||
sprintf($this->configManager->get('ldap.dn'), $login),
|
sprintf($this->configManager->get('ldap.dn'), $login),
|
||||||
$password
|
$password
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue