Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2024-02-17 13:04:16 +01:00
commit f4003f72e9

View File

@ -47,9 +47,21 @@ class SeedDMS_LdapAuthentication extends SeedDMS_Authentication {
if(isset($ldapgroups['count']))
$count = (int) $ldapgroups['count'];
for ($i = 0; $i < $count; $i++) {
$tmp = ldap_explode_dn($ldapgroups[$i], 1);
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]);
}
}