diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php index 017537ea..c3203fef 100644 --- a/inc/drivers_ldap.php +++ b/inc/drivers_ldap.php @@ -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.