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:
@@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user