--- loncom/auth/lonacc.pm 2011/06/13 02:44:36 1.136 +++ loncom/auth/lonacc.pm 2011/08/09 01:35:31 1.137 @@ -1,7 +1,7 @@ # The LearningOnline Network # Cookie Based Access Handler # -# $Id: lonacc.pm,v 1.136 2011/06/13 02:44:36 raeburn Exp $ +# $Id: lonacc.pm,v 1.137 2011/08/09 01:35:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -297,7 +297,9 @@ sub sso_login { my $home=&Apache::lonnet::homeserver($user,$domain); if ($home !~ /(con_lost|no_host|no_such_host)/) { &Apache::lonnet::logthis(" SSO authorized user $user "); - if ($r->dir_config("lonBalancer") eq 'yes') { + my ($is_balancer,$otherserver) = + &Apache::lonnet::check_loadbalancing($user,$domain); + if ($is_balancer) { # login but immediately go to switch server to find us a new # machine &Apache::lonauth::success($r,$user,$domain,$home,'noredirect'); @@ -306,7 +308,11 @@ sub sso_login { $env{'request.sso.reloginserver'} = $r->dir_config('lonSSOReloginServer'); } - $r->internal_redirect('/adm/switchserver'); + my $redirecturl = '/adm/switchserver'; + if ($otherserver ne '') { + $redirecturl .= '?otherserver='.$otherserver; + } + $r->internal_redirect($redirecturl); $r->set_handlers('PerlHandler'=> undef); } else { # need to login them in, so generate the need data that @@ -383,11 +389,7 @@ sub handler { return $result; } - - if ($r->dir_config("lonBalancer") eq 'yes') { - $r->set_handlers('PerlResponseHandler'=> - [\&Apache::switchserver::handler]); - } + my ($is_balancer,$otherserver); if ($handle eq '') { $r->log_reason("Cookie $handle not valid", $r->filename); @@ -434,6 +436,19 @@ sub handler { &Apache::lonacc::get_posted_cgi($r); +# ------------------------------------------------------ Check if load balancer + + ($is_balancer,$otherserver) = + &Apache::lonnet::check_loadbalancing($env{'user.name'}, + $env{'user.domain'}); + if ($is_balancer) { + $r->set_handlers('PerlResponseHandler'=> + [\&Apache::switchserver::handler]); + if ($otherserver ne '') { + $env{'form.otherserver'} = $otherserver; + } + } + # ---------------------------------------------------------------- Check access my $now = time; if ($requrl !~ m{^/(?:adm|public|prtspool)/} @@ -577,6 +592,17 @@ sub handler { } } return OK; + } else { + my $defdom=$r->dir_config('lonDefDomain'); + ($is_balancer,$otherserver) = + &Apache::lonnet::check_loadbalancing(undef,$defdom); + if ($is_balancer) { + $r->set_handlers('PerlResponseHandler'=> + [\&Apache::switchserver::handler]); + if ($otherserver ne '') { + $env{'form.otherserver'} = $otherserver; + } + } } # -------------------------------------------- See if this is a public resource if ($requrl=~m|^/+adm/+help/+|) {