Added option to use template string for bind DN (#90)

* Language update from launchpad

* Added login option 'bind_dn_template'
This commit is contained in:
Noone404
2020-02-19 23:11:17 +01:00
committed by GitHub
parent cbdc0dacd6
commit 4eb3737d31
5 changed files with 21 additions and 2 deletions

View File

@@ -255,7 +255,7 @@ class ldap extends DS {
if (! is_null($user)) {
# If login,attr is set to DN, then user should be a DN
if (($this->getValue('login','attr') == 'dn') || $method != 'user')
$userDN = $user;
$userDN = $this->getValue('login', 'bind_dn_template') ? $this->fillDNTemplate($user) : $user;
else
$userDN = $this->getLoginID($user,'login');
@@ -512,6 +512,15 @@ class ldap extends DS {
return $this->getBaseDN();
}
private function fillDNTemplate($user) {
foreach($this->getLoginBaseDN() as $base)
if(substr_compare($user, $base, -strlen($base)) === 0)
return $user; // $user already passed as DN
// fill template
return sprintf($this->getValue('login', 'bind_dn_template'), preg_replace('/([,\\\\#+<>;"=])/', '\\\\$1', $user));
}
/**
* Return the login classes that a user must have to login
*/