Active Directory

LDAP-Suche schlägt bei Namen mit Umlauten fehl

13. Oktober 2019 · Programmierung · andreas · Kein Kommentar

Solange ein Benuztername keinen Umlaut besitzt, kann man den Datensatz Daten mit dem Perl-Modul Net::LDAP recht einfach aus dem Active Directory auslesen:

use Net::LDAP;
$loginUser = Win32::LoginName();

$ldap = Net::LDAP->new($ldapServer) or die "$0";
$ldap->bind($ldapUser, $ldapPass});
$ldap_base = 'OU=Users';
$ldap_results = $ldap->search(base => $ldapBase, filter => "sAMAccountName=$loginUser");

if ($ldap_results->count) {
    # was ganz tolles mit dem Datensatz anstellen
}

Sofern aber ein Umlaut in dem Login-Namen steckt, so schlägt die Suche nach “benjamin.tröt” fehl, obwohl ein entsprechender sAMAccountName im Active Directory vorhanden ist.

Eine einfache Lösung bietet der Beitrag “Windows logon behavior if your user name contains characters that have accents or other diacritical marks”, welcher - auf das Login bezogen - folgende Ausweichmöglichkeit skizziert:

If your user name in the Active Directory directory service contains one or more characters that have accents or other diacritical marks, you may find that you do not have to use the diacritical mark as you type your user name to log on to Windows. You can log on by using the simple form of the character or characters. For example, if your user name in Active Directory is jésush, you can type jesush in the User name box in the Log On to Windows dialog box to log on to Windows.

Interessanterweise funktioniert dies auch bei LDAP-Anfragen im Active Directory, so daß eine Suche nach dem sAMAccountName “benjamin.trot” zum gewünschten Datensatz führt.

Stellt sich die Frage, was passiert, wenn tatsächlich ein Benjamin Trot neben seinem Kollegen Tröt Platz nimmt …