Skip to content

Commit

Permalink
New feature: LDAP auth group filtering, support for $userdn (#676)
Browse files Browse the repository at this point in the history
Dev: In the LDAP authentication module the group filtering can use the $userdn variable that contains the user DN. This feature is useful in a Active Directory environment where the groups contain the user DNs as members.
  • Loading branch information
epol authored and LouisGac committed Apr 20, 2017
1 parent 90acd71 commit fe8e8b8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions application/core/plugins/AuthLDAP/AuthLDAP.php
Expand Up @@ -108,7 +108,7 @@ class AuthLDAP extends ls\pluginmanager\AuthPluginBase
'groupsearchfilter' => array(
'type' => 'string',
'label' => 'Optional filter for group restriction',
'help' => 'Required if group search base set. E.g. (&(cn=limesurvey)(memberUid=$username))'
'help' => 'Required if group search base set. E.g. (&(cn=limesurvey)(memberUid=$username)) or (&(cn=limesurvey)(member=$userdn))'
)
);

Expand Down Expand Up @@ -515,7 +515,9 @@ public function newUserSession()
// If specifed, check group membership
if ($groupsearchbase != '' && $groupsearchfilter != '')
{
$filter = str_replace('$username', $username, $groupsearchfilter);
$keywords = array('$username','$userdn');
$substitutions = array($username,$userdn);
$filter = str_replace($keywords, $substitutions, $groupsearchfilter);
$groupsearchres = ldap_search($ldapconn, $groupsearchbase, $filter);
$grouprescount = ldap_count_entries($ldapconn, $groupsearchres);
if ($grouprescount < 1)
Expand Down

0 comments on commit fe8e8b8

Please sign in to comment.