diff --git a/inc/inc.ClassLdapAuthentication.php b/inc/inc.ClassLdapAuthentication.php index 987a6a4e9..ff4eb17b9 100644 --- a/inc/inc.ClassLdapAuthentication.php +++ b/inc/inc.ClassLdapAuthentication.php @@ -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]); } }