Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions auth-ldap/authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,16 @@ function($match) use ($username, $domain, $config) {
if (!$this->_bind($c))
return null;

$auth_filter = $this->getConfig()->get('use_custom_filters')?($this->getConfig()->get('auth_filter')):($schema['lookup']);

$r = $c->search(
$this->getSearchBase(),
str_replace(
array('{attr}','{q}'),
// Assume email address if the $username contains an @ sign
array(strpos($username, '@') ? $schema['email'] : $schema['username'],
$username),
$schema['lookup']),
$auth_filter),
array('sizelimit' => 1)
);
if (PEAR::isError($r) || !$r->count())
Expand Down Expand Up @@ -307,9 +309,12 @@ function search($query) {

$schema = static::$schemas[$this->getSchema($c)];
$schema = $schema['user'];

$search_filter = ($this->getConfig()->get('use_custom_filters'))?($this->getConfig()->get('search_filter')):($schema['search']);

$r = $c->search(
$this->getSearchBase(),
str_replace('{q}', $query, $schema['search']),
str_replace('{q}', $query, $search_filter),
array('attributes' => array_filter(flatten(array(
$schema['first'], $schema['last'], $schema['full'],
$schema['phone'], $schema['mobile'], $schema['email'],
Expand Down
21 changes: 21 additions & 0 deletions auth-ldap/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,27 @@ function($self, $val) use ($__) {
'2307' => 'Posix Account (rfc 2307)',
),
)),
'search_filter_options' => new SectionBreakField(array(
'label' => $__('Custom search filters'),
'hint' => $__('Custom search filter options in case the pre-supplied ones are non-sufficient.')
)),
'use_custom_filters' => new BooleanField(array(
'label' => $__('Use Custom Filters'),
'default' => false,
'configuration' => array(
'desc' => $__('Use Custom Search and Authentication Filters')
)
)),
'search_filter' => new TextboxField(array(
'label' => $__('LDAP Filter for searching users'),
'hint' => $__('Used when searching for users. {q} will be replaced with the search term.'),
'configuration' => array('size'=>70, 'length'=>160),
)),
'auth_filter' => new TextboxField(array(
'label' => $__('LDAP Filter for authentication'),
'hint' => $__('Used when authenticating. {q} will be replaced with the user id.'),
'configuration' => array('size'=>70, 'length'=>160),
)),

'auth' => new SectionBreakField(array(
'label' => $__('Authentication Modes'),
Expand Down