mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
propperly import group names with non-printable chars
This commit is contained in:
parent
98984619f6
commit
17dbfcf2c7
|
@ -47,9 +47,21 @@ class SeedDMS_LdapAuthentication extends SeedDMS_Authentication {
|
|||
if(isset($ldapgroups['count']))
|
||||
$count = (int) $ldapgroups['count'];
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if(0) {
|
||||
/* ldap_explode_dn() turns all utf-8 chars into \xx
|
||||
* This needs to be undone with the following regex.
|
||||
*/
|
||||
$tmp = ldap_explode_dn($ldapgroups[$i], 1);
|
||||
$tmp[0] = preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', function ($matches) { return chr(hexdec($matches[1])); }, $tmp[0]);
|
||||
} else {
|
||||
/* Second option would be to not using ldap_explode_dn()
|
||||
* and just extract the cn with
|
||||
* preg_match('/[^cn=]([^,]*)/i', $ldapgroups[$i], $tmp);
|
||||
*/
|
||||
preg_match('/[^cn=]([^,]*)/i', $ldapgroups[$i], $tmp);
|
||||
}
|
||||
if (!in_array($tmp[0], $groupnames)) {
|
||||
$groupnames[] = $tmp[0];
|
||||
$groupnames[] = preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', function ($matches) { return chr(hexdec($matches[1])); }, $tmp[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user