From f1ca12bbe93578328d95ef4016853e480b1e3f4b Mon Sep 17 00:00:00 2001 From: Florian Schlichting Date: Mon, 27 Mar 2017 16:56:34 +0200 Subject: [PATCH] Fix display of deactivated users after LDAP sync to not include those in $c->do_not_sync_from_ldap ...thus reducing the rate of heart attacks in DAViCal admins. Also: ignore empty user objects that my LDAP server seems to generate. --- inc/drivers_ldap.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php index d2adc153..05a294d0 100644 --- a/inc/drivers_ldap.php +++ b/inc/drivers_ldap.php @@ -594,6 +594,7 @@ function sync_LDAP(){ if ( sizeof($ldap_users_tmp) == 0 ) return; foreach($ldap_users_tmp as $key => $ldap_user){ + if(!isset($ldap_user[$mapping['username']])) continue; $ldap_users_info[$ldap_user[$mapping['username']]] = $ldap_user; unset($ldap_users_tmp[$key]); } @@ -652,8 +653,12 @@ function sync_LDAP(){ $params = array(); $i = 0; $paramstring = ''; - foreach( $users_to_deactivate AS $v ) { - if ( isset($c->do_not_sync_from_ldap) && isset($c->do_not_sync_from_ldap[$v]) ) continue; + foreach( $users_to_deactivate as $k => $v ) { + if ( isset($c->do_not_sync_from_ldap) && isset($c->do_not_sync_from_ldap[$v]) ) { + unset($users_to_deactivate[$k]); + $users_nothing_done[] = $v; + continue; + } if ( $i > 0 ) $paramstring .= ','; $paramstring .= ':u'.$i.'::text'; $params[':u'.$i++] = strtolower($v);