From 2e58b94c5b656d0293d8b5062dd0aaa00d387a8c Mon Sep 17 00:00:00 2001 From: rettenbe Date: Wed, 5 Nov 2008 15:26:10 +0000 Subject: [PATCH] server share login information with all other servers git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12926 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-server | 5 +---- gosa-si/server/events/clMessages.pm | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 4cb878816..80c1d78cb 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -180,7 +180,7 @@ my @foreign_clients_col_names = ("hostname VARCHAR(255)", "macaddress VARCHAR(17 our $login_users_db; our $login_users_tn = "login_users"; my $login_users_file_name; -my @login_users_col_names = ("client VARCHAR(255)", "user VARCHAR(255)", "timestamp VARCHAR(14)"); +my @login_users_col_names = ("client VARCHAR(255)", "user VARCHAR(255)", "timestamp VARCHAR(14)", "regserver VARCHAR(255) DEFAULT 'localhost'"); # holds all fai server, the debian release and tag our $fai_server_db; @@ -1017,9 +1017,6 @@ sub update_jobdb_status_for_send_msgs { # sending msg failed if( $error ) { - # JUST FOR TESTING - daemon_log("D \n$error\n$answer"); - # set jobs to done, jobs do not need to deliver their message in any case if (($job_header eq "trigger_action_localboot") ||($job_header eq "trigger_action_lock") diff --git a/gosa-si/server/events/clMessages.pm b/gosa-si/server/events/clMessages.pm index 5f23c351a..86e23aeea 100644 --- a/gosa-si/server/events/clMessages.pm +++ b/gosa-si/server/events/clMessages.pm @@ -122,11 +122,13 @@ sub LOGIN { # Invoke set_last_system; message sets ldap attributes 'gotoLastSystemLogin' and 'gotoLastSystem' $res = &set_last_system($msg, $msg_hash, $session_id); + # Add user to login_users_db my %add_hash = ( table=>$main::login_users_tn, primkey=> ['client', 'user'], client=>$source, user=>$login, timestamp=>&get_time, + regserver=>'localhost', ); ($res, $error_str) = $main::login_users_db->add_dbentry( \%add_hash ); if ($res != 0) { @@ -134,7 +136,11 @@ sub LOGIN { return; } - return; + # Share login information with all other si-server + my %data = ( 'new_user' => "$source;$login" ); + my $info_msg = &build_msg("information_sharing", $main::server_address, "KNOWN_SERVER", \%data); + + return ($info_msg); } @@ -195,6 +201,7 @@ sub CURRENTLY_LOGGED_IN { client=>$source, user=>$user, timestamp=>&get_time, + regserver=>'localhost', ); my ($res, $error_str) = $main::login_users_db->add_dbentry( \%add_hash ); if ($res != 0) { @@ -230,12 +237,16 @@ sub CURRENTLY_LOGGED_IN { &main::daemon_log("$session_id INFO: delete user '".$hit->{'user'}."' at client '".$hit->{'client'}."' from login_user_db", 5); } - # TODO # Inform all other server which users are logged in at clients registered at local server + my $info_sql = "SELECT * FROM $main::login_users_tn"; + my $info_res = $main::login_users_db->select_dbentry($info_sql); + my $info_msg_hash = &create_xml_hash("information_sharing", $main::server_address, "KNOWN_SERVER"); + while (my ($hit_id, $hit) = each(%$info_res)) { + &add_content2xml_hash($info_msg_hash, 'user_db', $hit->{'client'}.";".$hit->{'user'}); + } + my $info_msg = &create_xml_string($info_msg_hash); - # sende allen anderen server eine nachricht, "foreign_user_updates" zum beispiel - - return; + return ($info_msg); } -- 2.30.2