Fix an exception if a LDAP group mentions a user that doesn't exist

This tickles a bug as reported by Thorsten Marquardt in
https://sourceforge.net/p/davical/mailman/message/58766531/ with this
error message reported:

    Exception [0] ldap_get_attributes(): Argument #2 ($entry) must be of
    type LDAP\ResultEntry, false given
    At line 718 of /usr/share/davical-master/inc/drivers_ldap.php

You need to look in 3da860e5d5e732c2dedb62a73c76608a2b7098a4 for that line
number as I've just made some improvements to the code the last few commits.
This commit is contained in:
Andrew Ruthven 2024-05-01 00:27:31 +12:00
parent c273b38234
commit fcbd72e310

View File

@ -718,16 +718,21 @@ function sync_LDAP_groups(){
// in sync_LDAP and use more memory but not need
// anymore trips to LDAP.
$entry = ldap_read($ldapDriver->connect, $member, $filter,
$entry = $query($ldapDriver->connect, $member, $filter,
array($username_ldap_attribute));
$ldap_user_entry
= ldap_first_entry($ldapDriver->connect, $entry);
$ldap_user_attributes
= ldap_get_attributes($ldapDriver->connect,
$ldap_user_entry);
$ldap_members_tmp[]
= $ldap_user_attributes[$username_ldap_attribute][0];
if (! $ldap_user_entry) {
dbg_error_log( "ERROR", "%s not found in LDAP, not adding to group %s", $member, $group );
} else {
$ldap_user_attributes
= ldap_get_attributes($ldapDriver->connect,
$ldap_user_entry);
$ldap_members_tmp[]
= $ldap_user_attributes[$username_ldap_attribute][0];
}
}
} else {
// No need to rewrite.