Optimized LDAP error handling (references #1865)

This commit is contained in:
Bernd Bestel 2022-04-19 16:56:48 +02:00
parent 900a49a36a
commit 6ad761e067
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300

View File

@ -42,7 +42,16 @@ class LdapAuthMiddleware extends AuthMiddleware
$filter = '(&(' . GROCY_LDAP_UID_ATTR . '=' . $postParams['username'] . ')' . GROCY_LDAP_USER_FILTER . ')';
$search = ldap_search($connect, GROCY_LDAP_BASE_DN, $filter);
if ($search === false)
{
throw new \Exception('LDAP error: ' . ldap_error($connect));
}
$result = ldap_get_entries($connect, $search);
if ($result === false)
{
throw new \Exception('LDAP error: ' . ldap_error($connect));
}
$ldapFirstName = $result[0]['givenname'][0];
$ldapLastName = $result[0]['sn'][0];