Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply group mappings to groupOfUniqueNames LDAP groups too #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
19 changes: 17 additions & 2 deletions www/include/auth/ldap.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,24 @@ function getUserData($user,$inbind=false) {

if(is_array($result)) foreach($result as $grp){
if(!empty($grp[$this->cnf['groupkey']][0])){
$groupname = $grp[$this->cnf['groupkey']][0];
if($this->cnf['debug'])
printmsg('DEBUG => auth_ldap: LDAP usergroup: '.htmlspecialchars($grp[$this->cnf['groupkey']][0]),2);
$info['grps'][$grp[$this->cnf['groupkey']][0]] = $g++;
printmsg('DEBUG => auth_ldap: LDAP usergroup: '
.htmlspecialchars($groupname),2);
if(!empty($this->cnf['mapping']['grps'][$this->cnf['groupkey']])){
$regexp = $this->cnf['mapping']['grps'][$this->cnf['groupkey']];
printmsg('DEBUG => Matching '.htmlspecialchars($groupname)
.' against '.htmlspecialchars($regexp),2);
if (preg_match($regexp,$groupname,$match)) {
$groupname_mapped = $match[1];
if($this->cnf['debug'])
printmsg('DEBUG => auth_ldap: mapped LDAP usergroup: '
.htmlspecialchars($groupname_mapped),2);
$info['grps'][$groupname_mapped] = $g++;
}
} else {
$info['grps'][$groupname] = $g++;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion www/include/functions_auth.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function get_authentication($login_name='', $login_password='') {
$js = "el('loginmsg').innerHTML = '<span style=\"color: green;\">Success!</span>'; setTimeout('removeElement(\'tt_loginform\')',1000);";

// Validate the userid was passed and is "clean"
if (!preg_match('/^[A-Za-z0-9.\-_]+$/', $login_name)) {
if (!preg_match('/^[A-Za-z0-9.\-_@]+$/', $login_name)) {
$js = "el('loginmsg').innerHTML = 'Bad username format';";
printmsg("ERROR => Login failure for {$login_name}: Bad username format", 0);
return(array(1, $js));
Expand Down