From 0bc51a9e3914eb4128160ee78f1ab1cf15267580 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Wed, 13 Feb 2008 12:33:27 +1300 Subject: [PATCH] Work on "Sync LDAP with RSCDS" feature. * Use an ugly hack so that users that are updated using the Sync LDAP feature retain their user_no. Otherwise a new user_no was selected, and the insert failed since the username already existed. * Tidy up the output messages to be more consistent. * Only display "updating user records" if users were updated. --- inc/drivers_ldap.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php index 648d1043..8d312e6e 100644 --- a/inc/drivers_ldap.php +++ b/inc/drivers_ldap.php @@ -349,7 +349,7 @@ function sync_LDAP(){ $usr_in .= ', ' . qpg($v); } $usr_in = substr($usr_in,1); - $c->messages[] = sprintf(i18n('- deactivating users : %s'),$usr_in); + $c->messages[] = sprintf(i18n('- deactivating users : %s'),join(', ',$users_to_deactivate)); $qry = new PgQuery( "UPDATE usr SET active = FALSE WHERE lower(username) IN ($usr_in)"); $qry->Exec('sync_LDAP',__LINE__,__FILE__); } @@ -360,6 +360,9 @@ function sync_LDAP(){ $valid=$ldap_users_info[$username]; $ldap_timestamp = $valid[$mapping["updated"]]; + $valid["user_no"] = $db_users_info[$username]["user_no"]; + $mapping["user_no"] = "user_no"; + /** * This splits the LDAP timestamp apart and assigns values to $Y $m $d $H $M and $S */ @@ -377,9 +380,10 @@ function sync_LDAP(){ $users_nothing_done[] = $username; } } - $c->messages[] = sprintf(i18n('- updating user record %s'),join(', ',$users_to_update)); + if ( sizeof($users_to_update) ) + $c->messages[] = sprintf(i18n('- updating user records : %s'),join(', ',$users_to_update)); if ( sizeof($users_nothing_done) ) - $c->messages[] = sprintf(i18n('- nothing done on %s'),join(', ', $users_nothing_done)); + $c->messages[] = sprintf(i18n('- nothing done on : %s'),join(', ', $users_nothing_done)); } } }