Annotation of loncom/auth/lonauth.pm, revision 1.170
1.136 kruse 1: # The LearningOnline Network
2: # User Authentication Module
3: #
1.170 ! raeburn 4: # $Id: lonauth.pm,v 1.169 2021/11/03 01:04:02 raeburn Exp $
1.136 kruse 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::lonauth;
30:
31: use strict;
1.140 raeburn 32: use LONCAPA qw(:DEFAULT :match);
1.136 kruse 33: use Apache::Constants qw(:common);
34: use CGI qw(:standard);
35: use Apache::loncommon();
36: use Apache::lonnet;
37: use Apache::lonmenu();
38: use Apache::createaccount;
1.149 raeburn 39: use Apache::ltiauth;
1.136 kruse 40: use Fcntl qw(:flock);
41: use Apache::lonlocal;
42: use Apache::File();
43: use HTML::Entities;
1.143 raeburn 44: use Digest::MD5;
1.170 ! raeburn 45: use CGI::Cookie();
1.136 kruse 46:
47: # ------------------------------------------------------------ Successful login
48: sub success {
49: my ($r, $username, $domain, $authhost, $lowerurl, $extra_env,
1.170 ! raeburn 50: $form,$skipcritical,$cid,$expirepub) = @_;
1.136 kruse 51:
52: # ------------------------------------------------------------ Get cookie ready
53: my $cookie =
54: &Apache::loncommon::init_user_environment($r, $username, $domain,
55: $authhost, $form,
56: {'extra_env' => $extra_env,});
57:
58: my $public=($username eq 'public' && $domain eq 'public');
59:
60: if ($public or $lowerurl eq 'noredirect') { return $cookie; }
61:
62: # -------------------------------------------------------------------- Log this
63:
1.162 raeburn 64: my $ip = &Apache::lonnet::get_requestor_ip();
1.136 kruse 65: &Apache::lonnet::log($domain,$username,$authhost,
1.162 raeburn 66: "Login $ip");
1.136 kruse 67:
68: # ------------------------------------------------- Check for critical messages
69:
1.149 raeburn 70: unless ($skipcritical) {
71: my @what=&Apache::lonnet::dump('critical',$domain,$username);
72: if ($what[0]) {
73: if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) {
74: $lowerurl='/adm/email?critical=display';
75: }
1.136 kruse 76: }
77: }
78:
1.143 raeburn 79: # ----------------------------------------------------------- Get cookies ready
80: my ($securecookie,$defaultcookie);
1.154 raeburn 81: my $ssl = $r->subprocess_env('https');
82: if ($ssl) {
83: $securecookie="lonSID=$cookie; path=/; HttpOnly; secure";
1.143 raeburn 84: my $lonidsdir=$r->dir_config('lonIDsDir');
85: if (($lonidsdir) && (-e "$lonidsdir/$cookie.id")) {
86: my $linkname=substr(Digest::MD5::md5_hex(Digest::MD5::md5_hex(time(). {}. rand(). $$)), 0, 32).'_linked';
87: if (-e "$lonidsdir/$linkname.id") {
88: unlink("$lonidsdir/$linkname.id");
89: }
90: my $made_symlink = eval { symlink("$lonidsdir/$cookie.id",
91: "$lonidsdir/$linkname.id"); 1 };
92: if ($made_symlink) {
93: $defaultcookie = "lonLinkID=$linkname; path=/; HttpOnly;";
1.154 raeburn 94: &Apache::lonnet::appenv({'user.linkedenv' => $linkname});
1.143 raeburn 95: }
96: }
97: } else {
98: $defaultcookie = "lonID=$cookie; path=/; HttpOnly;";
99: }
1.136 kruse 100: # -------------------------------------------------------- Menu script and info
101: my $destination = $lowerurl;
1.149 raeburn 102: if ($env{'request.lti.login'}) {
103: if (($env{'request.lti.reqcrs'}) && ($env{'request.lti.reqrole'} eq 'cc')) {
104: &Apache::loncommon::content_type($r,'text/html');
105: if ($securecookie) {
106: $r->headers_out->add('Set-cookie' => $securecookie);
107: }
108: if ($defaultcookie) {
109: $r->headers_out->add('Set-cookie' => $defaultcookie);
110: }
111: $r->send_http_header;
1.152 raeburn 112: if (ref($form) eq 'HASH') {
1.158 raeburn 113: $form->{'lti.login'} = $env{'request.lti.login'};
1.152 raeburn 114: $form->{'lti.reqcrs'} = $env{'request.lti.reqcrs'};
115: $form->{'lti.reqrole'} = $env{'request.lti.reqrole'};
116: $form->{'lti.sourcecrs'} = $env{'request.lti.sourcecrs'};
117: }
1.149 raeburn 118: &Apache::ltiauth::lti_reqcrs($r,$domain,$form,$username,$domain);
119: return;
120: }
121: if ($env{'request.lti.selfenrollrole'}) {
122: if (&Apache::ltiauth::lti_enroll($username,$domain,
123: $env{'request.lti.selfenrollrole'}) eq 'ok') {
124: $form->{'role'} = $env{'request.lti.selfenrollrole'};
125: &Apache::lonnet::delenv('request.lti.selfenrollrole');
126: } else {
127: &Apache::ltiauth::invalid_request($r,24);
128: }
129: }
130: }
1.136 kruse 131: if (defined($form->{role})) {
132: my $envkey = 'user.role.'.$form->{role};
133: my $now=time;
134: my $then=$env{'user.login.time'};
135: my $refresh=$env{'user.refresh.time'};
136: my $update=$env{'user.update.time'};
137: if (!$update) {
138: $update = $then;
139: }
140: if (exists($env{$envkey})) {
141: my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus);
142: &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,
143: \$trolecode,\$tstatus,\$tstart,\$tend);
144: if ($tstatus eq 'is') {
145: $destination .= ($destination =~ /\?/) ? '&' : '?';
146: my $newrole = &HTML::Entities::encode($form->{role},'"<>&');
147: $destination .= 'selectrole=1&'.$newrole.'=1';
148: }
149: }
150: }
151: if (defined($form->{symb})) {
152: my $destsymb = $form->{symb};
1.159 raeburn 153: my $encrypted;
154: if ($destsymb =~ m{^/enc/}) {
155: $encrypted = 1;
156: if ($cid) {
157: $destsymb = &Apache::lonenc::unencrypted($destsymb,$cid);
158: }
159: }
1.136 kruse 160: $destination .= ($destination =~ /\?/) ? '&' : '?';
161: if ($destsymb =~ /___/) {
162: my ($map,$resid,$desturl)=split(/___/,$destsymb);
1.137 raeburn 163: $desturl = &Apache::lonnet::clutter($desturl);
1.159 raeburn 164: if ($encrypted) {
165: $desturl = &Apache::lonenc::encrypted($desturl,1,$cid);
166: $destsymb = $form->{symb};
167: }
1.136 kruse 168: $desturl = &HTML::Entities::encode($desturl,'"<>&');
169: $destsymb = &HTML::Entities::encode($destsymb,'"<>&');
170: $destination .= 'destinationurl='.$desturl.
171: '&destsymb='.$destsymb;
1.159 raeburn 172: } elsif (!$encrypted) {
1.136 kruse 173: $destsymb = &HTML::Entities::encode($destsymb,'"<>&');
174: $destination .= 'destinationurl='.$destsymb;
175: }
176: }
177: if ($destination =~ m{^/adm/roles}) {
178: $destination .= ($destination =~ /\?/) ? '&' : '?';
179: $destination .= 'source=login';
180: }
181:
1.169 raeburn 182: if (($env{'request.deeplink.login'} eq $lowerurl) &&
183: (($env{'request.linkprot'}) || ($env{'request.linkkey'} ne ''))) {
184: my %info;
185: if ($env{'request.linkprot'}) {
186: $info{'linkprot'} = $env{'request.linkprot'};
187: } elsif ($env{'request.linkkey'} ne '') {
188: $info{'linkkey'} = $env{'request.linkkey'};
189: }
190: $info{'origurl'} = $lowerurl;
191: my $token = &Apache::lonnet::tmpput(\%info,$r->dir_config('lonHostID'),'link');
192: unless (($token eq 'con_lost') || ($token eq 'refused') ||
193: ($token eq 'unknown_cmd') || ($token eq 'no_such_host')) {
194: $destination .= (($destination =~ /\?/) ? '&' : '?') . 'ttoken='.$token;
195: }
196: }
197:
1.150 raeburn 198: my $windowname = 'loncapaclient';
199: if ($env{'request.lti.login'}) {
200: $windowname .= 'lti';
201: }
202: my $windowinfo = Apache::lonhtmlcommon::scripttag('self.name="'.$windowname.'";');
1.136 kruse 203: my $brcrum = [{'href' => '',
204: 'text' => 'Successful Login'},];
1.140 raeburn 205: my $args = {'bread_crumbs' => $brcrum,};
206: unless ((defined($form->{role})) || (defined($form->{symb}))) {
207: my $update=$env{'user.update.time'};
208: if (!$update) {
209: $update = $env{'user.login.time'};
210: }
211: my %roles_in_env;
212: my $showcount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update);
213: if ($showcount == 1) {
214: foreach my $rolecode (keys(%roles_in_env)) {
215: my ($cid) = ($rolecode =~ m{^\Quser.role.st./\E($match_domain/$match_courseid)(?:/|$)});
216: if ($cid) {
217: my %coursedescription =
218: &Apache::lonnet::coursedescription($cid,{'one_time' => '1'});
219: if ($coursedescription{'type'} eq 'Placement') {
220: $args->{'crstype'} = 'Placement';
221: }
222: last;
223: }
224: }
225: }
226: }
1.136 kruse 227:
228: # ------------------------------------------------- Output for successful login
229:
230: &Apache::loncommon::content_type($r,'text/html');
1.143 raeburn 231: if ($securecookie) {
232: $r->headers_out->add('Set-cookie' => $securecookie);
233: }
234: if ($defaultcookie) {
235: $r->headers_out->add('Set-cookie' => $defaultcookie);
236: }
1.170 ! raeburn 237: if ($expirepub) {
! 238: my $c = new CGI::Cookie(-name => 'lonPubID',
! 239: -value => '',
! 240: -expires => '-10y',);
! 241: $r->headers_out->add('Set-cookie' => $c);
! 242: }
1.136 kruse 243: $r->send_http_header;
244:
1.153 raeburn 245: my ($start_page,$js,$pagebody,$end_page);
1.151 raeburn 246: if ($env{'request.lti.login'}) {
1.153 raeburn 247: $args = {'only_body' => 1};
248: if ($env{'request.lti.target'} eq '') {
249: my $ltitarget = (($destination =~ /\?/) ? '&' : '?').
250: 'ltitarget=iframe';
251: $js = <<"ENDJS";
252:
253: <script type="text/javascript">
254: // <![CDATA[
255: function setLTItarget() {
256: var newloc = '$destination';
257: if (parent !== window) {
258: newloc += '$ltitarget';
259: }
260: window.location.href=newloc;
261: }
262: // ]]>
263: </script>
264:
265: ENDJS
266: $args->{'add_entries'} = {'onload' => "javascript:setLTItarget();"};
267: $pagebody = '<noscript><span class="LC_warning">'
268: .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
269: .'</span></noscript>';
270: } else {
271: $args->{'redirect'} = [0,$destination,1];
272: }
273: $start_page=&Apache::loncommon::start_page('',$js,$args);
1.151 raeburn 274: } else {
1.153 raeburn 275: $args->{'redirect'} = [0,$destination];
1.151 raeburn 276: $start_page=&Apache::loncommon::start_page('Successful Login',
1.153 raeburn 277: $js,$args);
1.149 raeburn 278:
1.151 raeburn 279: my %lt=&Apache::lonlocal::texthash(
280: 'wel' => 'Welcome',
281: 'pro' => 'Login problems?',
282: );
283: $pagebody = "<h1>$lt{'wel'}</h1>\n".
284: &mt('Welcome to the Learning[_1]Online[_2] Network with CAPA. Please wait while your session is being set up.','<i>','</i>');
285: my $loginhelp = &loginhelpdisplay($domain);
286: if ($loginhelp) {
287: $pagebody .= '<p><a href="'.$loginhelp.'">'.$lt{'pro'}.'</a></p>';
288: }
1.136 kruse 289: }
1.153 raeburn 290: $end_page = &Apache::loncommon::end_page();
1.136 kruse 291: $r->print(<<ENDSUCCESS);
292: $start_page
293: $windowinfo
1.151 raeburn 294: $pagebody
1.136 kruse 295: $end_page
296: ENDSUCCESS
297: return;
298: }
299:
300: # --------------------------------------------------------------- Failed login!
301:
302: sub failed {
303: my ($r,$message,$form) = @_;
304: (undef,undef,undef,my $clientmathml,my $clientunicode) =
305: &Apache::loncommon::decode_user_agent();
306: my $args = {};
307: if ($clientunicode && !$clientmathml) {
308: $args = {'browser.unicode' => 1};
309: }
310:
311: my $start_page = &Apache::loncommon::start_page('Unsuccessful Login',undef,$args);
312: my $uname = &Apache::loncommon::cleanup_html($form->{'uname'});
313: my $udom = &Apache::loncommon::cleanup_html($form->{'udom'});
314: if (&Apache::lonnet::domain($udom,'description') eq '') {
315: undef($udom);
316: }
317: my $retry = '/adm/login';
318: if ($uname eq $form->{'uname'}) {
319: $retry .= '?username='.$uname;
320: }
321: if ($udom) {
322: $retry .= (($retry=~/\?/)?'&':'?').'domain='.$udom;
323: }
1.168 raeburn 324: my $lonhost = $r->dir_config('lonHostID');
325: my $querystr;
326: my $result = &set_retry_token($form,$lonhost,\$querystr);
327: if ($result eq 'fail') {
328: if (exists($form->{role})) {
329: my $role = &Apache::loncommon::cleanup_html($form->{role});
330: if ($role ne '') {
331: $retry .= (($retry=~/\?/)?'&':'?').'role='.$role;
332: }
333: }
334: if (exists($form->{symb})) {
335: my $symb = &Apache::loncommon::cleanup_html($form->{symb});
336: if ($symb ne '') {
337: $retry .= (($retry=~/\?/)?'&':'?').'symb='.$symb;
338: }
339: }
340: if (exists($form->{firsturl})) {
341: my $firsturl = &Apache::loncommon::cleanup_html($form->{firsturl});
342: if ($firsturl ne '') {
343: $retry .= (($retry=~/\?/)?'&':'?').'firsturl='.$firsturl;
344: if ($form->{firsturl} =~ m{^/tiny/$match_domain/\w+$}) {
345: unless (exists($form->{linkprot})) {
346: if (exists($form->{linkkey})) {
347: $retry .= 'linkkey='.$form->{linkkey};
348: }
1.157 raeburn 349: }
350: }
351: }
1.155 raeburn 352: }
1.168 raeburn 353: if (exists($form->{linkprot})) {
354: my $ltoken = &Apache::lonnet::tmpput({linkprot => $form->{'linkprot'}},
1.169 raeburn 355: $r->dir_config('lonHostID'),'retry');
1.168 raeburn 356: if ($ltoken) {
357: $retry .= (($retry =~ /\?/) ? '&' : '?').'ltoken='.$ltoken;
358: }
1.156 raeburn 359: }
1.168 raeburn 360: } elsif ($querystr ne '') {
361: $retry .= (($retry=~/\?/)?'&':'?').$querystr;
1.156 raeburn 362: }
1.136 kruse 363: my $end_page = &Apache::loncommon::end_page();
364: &Apache::loncommon::content_type($r,'text/html');
365: $r->send_http_header;
366: my @actions =
367: (&mt('Please [_1]log in again[_2].','<a href="'.$retry.'">','</a>'));
368: my $loginhelp = &loginhelpdisplay($udom);
369: if ($loginhelp) {
370: push(@actions, '<a href="'.$loginhelp.'">'.&mt('Login problems?').'</a>');
371: }
372: #FIXME: link to helpdesk might be added here
373:
374: $r->print(
375: $start_page
376: .'<h2>'.&mt('Sorry ...').'</h2>'
377: .&Apache::lonhtmlcommon::confirm_success(&mt($message),1).'<br /><br />'
378: .&Apache::lonhtmlcommon::actionbox(\@actions)
379: .$end_page
380: );
381: }
382:
383: # ------------------------------------------------------------------ Rerouting!
384:
385: sub reroute {
386: my ($r) = @_;
387: &Apache::loncommon::content_type($r,'text/html');
388: $r->send_http_header;
389: my $msg='<b>'.&mt('Sorry ...').'</b><br />'
390: .&mt('Please [_1]log in again[_2].');
391: &Apache::loncommon::simple_error_page($r,'Rerouting',$msg,{'no_auto_mt_msg' => 1});
392: }
393:
394: # ---------------------------------------------------------------- Main handler
395:
396: sub handler {
397: my $r = shift;
398: my $londocroot = $r->dir_config('lonDocRoot');
399: # Are we re-routing?
400: if (-e "$londocroot/lon-status/reroute.txt") {
401: &reroute($r);
402: return OK;
403: }
404:
405: &Apache::lonlocal::get_language_handle($r);
406:
407: # -------------------------------- Prevent users from attempting to login twice
408: my $handle = &Apache::lonnet::check_for_valid_session($r);
409: if ($handle ne '') {
410: my $lonidsdir=$r->dir_config('lonIDsDir');
411: if ($handle=~/^publicuser\_/) {
412: # For "public user" - remove it, we apparently really want to login
413: unlink($r->dir_config('lonIDsDir')."/$handle.id");
414: } else {
415: # Indeed, a valid token is found
416: &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
417: &Apache::loncommon::content_type($r,'text/html');
418: $r->send_http_header;
1.166 raeburn 419: my $start_page =
1.136 kruse 420: &Apache::loncommon::start_page('Already logged in');
421: my $end_page =
422: &Apache::loncommon::end_page();
423: my $dest = '/adm/roles';
1.169 raeburn 424: my %form = &get_form_items($r);
425: if ($form{'logtoken'}) {
426: my $tmpinfo = &Apache::lonnet::reply('tmpget:'.$form{'logtoken'},
427: $form{'serverid'});
428: unless (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost') ||
429: ($tmpinfo eq 'no_such_host')) {
430: my ($des_key,$firsturl,@rest)=split(/&/,$tmpinfo);
431: $firsturl = &unescape($firsturl);
432: my %info;
433: foreach my $item (@rest) {
434: my ($key,$value) = split(/=/,$item);
435: $info{$key} = &unescape($value);
436: }
437: if ($firsturl ne '') {
438: $info{'firsturl'} = $firsturl;
439: $dest = $firsturl;
440: my $relogin;
441: if ($dest =~ m{^/tiny/$match_domain/\w+$}) {
442: if ($env{'request.course.id'}) {
443: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
444: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
445: my $symb = &Apache::loncommon::symb_from_tinyurl($dest,$cnum,$cdom);
446: if ($symb) {
447: unless (&set_deeplink_login(%info) eq 'ok') {
448: $relogin = 1;
449: }
450: }
451: }
452: if ($relogin) {
453: $r->print(
454: $start_page
455: .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
456: .'<p>'.&mt('Please [_1]log out[_2] first, and then try your access again',
457: '<a href="/adm/logout">','</a>')
458: .'</p>'
459: .$end_page);
460: } else {
461: if (($info{'linkprot'}) || ($info{'linkkey'} ne '')) {
462: my $token = &Apache::lonnet::tmpput(\%info,$r->dir_config('lonHostID'),'link');
463: unless (($token eq 'con_lost') || ($token eq 'refused') ||
464: ($token eq 'unknown_cmd') || ($token eq 'no_such_host')) {
465: $dest .= (($dest =~ /\?/) ? '&' : '?') . 'ttoken='.$token;
466: }
467: }
468: $r->print(
469: $start_page
470: .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
471: .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4] first, and then try your access again',
472: '<a href="'.$dest.'">','</a>',
473: '<a href="/adm/logout">','</a>')
474: .'</p>'
475: .$end_page);
476: }
477: return OK;
1.164 raeburn 478: }
479: }
1.157 raeburn 480: }
1.136 kruse 481: }
482: $r->print(
1.169 raeburn 483: $start_page
484: .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
485: .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].'
486: ,'<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>')
487: .'</p>'
488: .$end_page
1.136 kruse 489: );
490: return OK;
491: }
492: }
493:
494: # ---------------------------------------------------- No valid token, continue
495:
1.169 raeburn 496: my %form = &get_form_items($r);
1.136 kruse 497: if ((!$form{'uname'}) || (!$form{'upass0'}) || (!$form{'udom'})) {
498: &failed($r,'Username, password and domain need to be specified.',
499: \%form);
500: return OK;
501: }
502:
503: # split user logging in and "su"-user
504:
1.145 raeburn 505: ($form{'uname'},$form{'suname'},$form{'sudom'})=split(/\:/,$form{'uname'});
1.136 kruse 506: $form{'uname'} = &LONCAPA::clean_username($form{'uname'});
507: $form{'suname'}= &LONCAPA::clean_username($form{'suname'});
1.145 raeburn 508: $form{'udom'} = &LONCAPA::clean_domain($form{'udom'});
509: $form{'sudom'} = &LONCAPA::clean_domain($form{'sudom'});
1.136 kruse 510:
511: my $role = $r->dir_config('lonRole');
512: my $domain = $r->dir_config('lonDefDomain');
513: my $prodir = $r->dir_config('lonUsersDir');
514: my $contact_name = &mt('LON-CAPA helpdesk');
515:
516: # ---------------------------------------- Get the information from login token
517:
518: my $tmpinfo=Apache::lonnet::reply('tmpget:'.$form{'logtoken'},
519: $form{'serverid'});
520:
521: if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost') ||
522: ($tmpinfo eq 'no_such_host')) {
523: &failed($r,'Information needed to verify your login information is missing, inaccessible or expired.',\%form);
524: return OK;
525: } else {
526: my $reply = &Apache::lonnet::reply('tmpdel:'.$form{'logtoken'},
527: $form{'serverid'});
528: if ( $reply ne 'ok' ) {
529: &failed($r,'Session could not be opened.',\%form);
530: &Apache::lonnet::logthis("ERROR got a reply of $reply when trying to contact ". $form{'serverid'}." to get login token");
531: return OK;
532: }
533: }
534:
535: if (!&Apache::lonnet::domain($form{'udom'})) {
536: &failed($r,'The domain you provided is not a valid LON-CAPA domain.',\%form);
537: return OK;
538: }
539:
1.169 raeburn 540: my ($des_key,$firsturl,@rest)=split(/&/,$tmpinfo);
541: $firsturl = &unescape($firsturl);
1.168 raeburn 542: foreach my $item (@rest) {
543: my ($key,$value) = split(/=/,$item);
544: $form{$key} = &unescape($value);
1.156 raeburn 545: }
1.155 raeburn 546: if ($firsturl =~ m{^/tiny/$match_domain/\w+$}) {
547: $form{'firsturl'} = $firsturl;
548: }
1.139 raeburn 549: my $upass = $ENV{HTTPS} ? $form{'upass0'}
1.169 raeburn 550: : &Apache::loncommon::des_decrypt($des_key,$form{'upass0'});
1.136 kruse 551:
552: # ---------------------------------------------------------------- Authenticate
553:
554: my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'});
555: my ($cancreate,$statustocreate) =
556: &Apache::createaccount::get_creation_controls($form{'udom'},$domconfig{'usercreation'});
557: my $defaultauth;
558: if (ref($cancreate) eq 'ARRAY') {
559: if (grep(/^login$/,@{$cancreate})) {
560: $defaultauth = 1;
561: }
562: }
563: my $clientcancheckhost = 1;
564: my $authhost=Apache::lonnet::authenticate($form{'uname'},$upass,
565: $form{'udom'},$defaultauth,
566: $clientcancheckhost);
1.149 raeburn 567:
1.136 kruse 568: # --------------------------------------------------------------------- Failed?
569:
570: if ($authhost eq 'no_host') {
571: &failed($r,'Username and/or password could not be authenticated.',
572: \%form);
573: return OK;
574: } elsif ($authhost eq 'no_account_on_host') {
575: if ($defaultauth) {
576: my $domdesc = &Apache::lonnet::domain($form{'udom'},'description');
577: unless (&check_can_host($r,\%form,'no_account_on_host',$domdesc)) {
578: return OK;
579: }
580: my $start_page =
1.168 raeburn 581: &Apache::loncommon::start_page('Create a user account in LON-CAPA',
582: '',{'no_inline_link' => 1,});
1.136 kruse 583: my $lonhost = $r->dir_config('lonHostID');
584: my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
585: my $contacts =
586: &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
587: $form{'udom'},$origmail);
588: my ($contact_email) = split(',',$contacts);
589: my $output =
590: &Apache::createaccount::username_check($form{'uname'},$form{'udom'},
591: $domdesc,'',$lonhost,
592: $contact_email,$contact_name,
593: undef,$statustocreate);
594: &Apache::loncommon::content_type($r,'text/html');
595: $r->send_http_header;
596: &Apache::createaccount::print_header($r,$start_page);
597: $r->print('<h3>'.&mt('Account creation').'</h3>'.
598: &mt('Although your username and password were authenticated, you do not currently have a LON-CAPA account at this institution.').'<br />'.
599: $output.&Apache::loncommon::end_page());
600: return OK;
601: } else {
602: &failed($r,'Although your username and password were authenticated, you do not currently have a LON-CAPA account in this domain, and you are not permitted to create one.',\%form);
603: return OK;
604: }
605: }
606:
607: if (($firsturl eq '') ||
608: ($firsturl=~/^\/adm\/(logout|remote)/)) {
609: $firsturl='/adm/roles';
610: }
611:
1.169 raeburn 612: my ($hosthere,%sessiondata);
1.136 kruse 613: if ($form{'iptoken'}) {
1.169 raeburn 614: %sessiondata = &Apache::lonnet::tmpget($form{'iptoken'});
1.138 raeburn 615: my $delete = &Apache::lonnet::tmpdel($form{'iptoken'});
1.136 kruse 616: if (($sessiondata{'domain'} eq $form{'udom'}) &&
617: ($sessiondata{'username'} eq $form{'uname'})) {
618: $hosthere = 1;
619: }
620: }
621:
622: # --------------------------------- Are we attempting to login as somebody else?
623: if ($form{'suname'}) {
1.145 raeburn 624: my ($suname,$sudom,$sudomref);
625: $suname = $form{'suname'};
626: $sudom = $form{'udom'};
627: if ($form{'sudom'}) {
628: unless ($sudom eq $form{'sudom'}) {
629: if (&Apache::lonnet::domain($form{'sudom'})) {
630: $sudomref = [$form{'sudom'}];
631: $sudom = $form{'sudom'};
632: }
633: }
634: }
1.136 kruse 635: # ------------ see if the original user has enough privileges to pull this stunt
1.145 raeburn 636: if (&Apache::lonnet::privileged($form{'uname'},$form{'udom'},$sudomref)) {
1.136 kruse 637: # ---------------------------------------------------- see if the su-user exists
1.145 raeburn 638: unless (&Apache::lonnet::homeserver($suname,$sudom) eq 'no_host') {
1.136 kruse 639: # ------------------------------ see if the su-user is not too highly privileged
1.146 raeburn 640: if (&Apache::lonnet::privileged($suname,$sudom)) {
641: &Apache::lonnet::logthis('Attempted switch user to privileged user');
642: } else {
643: my $noprivswitch;
1.145 raeburn 644: #
645: # su-user's home server and user's home server must have one of:
1.147 raeburn 646: # (a) same domain
647: # (b) same primary library server for the two domains
648: # (c) same "internet domain" for primary library server(s) for home servers' domains
1.145 raeburn 649: #
1.148 raeburn 650: my $suprim = &Apache::lonnet::domain($sudom,'primary');
651: my $suintdom = &Apache::lonnet::internet_dom($suprim);
1.145 raeburn 652: unless ($sudom eq $form{'udom'}) {
1.148 raeburn 653: my $uprim = &Apache::lonnet::domain($form{'udom'},'primary');
654: my $uintdom = &Apache::lonnet::internet_dom($uprim);
1.145 raeburn 655: unless ($suprim eq $uprim) {
656: unless ($suintdom eq $uintdom) {
657: &Apache::lonnet::logthis('Attempted switch user '
1.169 raeburn 658: .'to user with different "internet domain".');
1.146 raeburn 659: $noprivswitch = 1;
1.145 raeburn 660: }
661: }
662: }
663:
1.146 raeburn 664: unless ($noprivswitch) {
665: #
666: # server where log-in occurs must have same "internet domain" as su-user's home
667: # server
668: #
669: my $lonhost = $r->dir_config('lonHostID');
670: my $hostintdom = &Apache::lonnet::internet_dom($lonhost);
1.148 raeburn 671: if ($hostintdom ne $suintdom) {
1.146 raeburn 672: &Apache::lonnet::logthis('Attempted switch user on a '
673: .'server with a different "internet domain".');
674: } else {
675:
1.136 kruse 676: # -------------------------------------------------------- actually switch users
1.145 raeburn 677:
1.146 raeburn 678: &Apache::lonnet::logperm('User '.$form{'uname'}.' at '.
679: $form{'udom'}.' logging in as '.$suname.':'.$sudom);
680: $form{'uname'}=$suname;
681: if ($form{'udom'} ne $sudom) {
682: $form{'udom'}=$sudom;
683: }
684: }
1.145 raeburn 685: }
1.136 kruse 686: }
687: }
688: } else {
689: &Apache::lonnet::logthis('Non-privileged user attempting switch user');
690: }
691: }
692:
693: my ($is_balancer,$otherserver);
694:
695: unless ($hosthere) {
696: ($is_balancer,$otherserver) =
1.141 raeburn 697: &Apache::lonnet::check_loadbalancing($form{'uname'},$form{'udom'},'login');
698: if ($is_balancer) {
1.161 raeburn 699: # Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)
700: my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r);
701: if (($found_server) && ($balancer_cookie =~ /^\Q$env{'user.domain'}\E_\Q$env{'user.name'}\E_/)) {
702: $otherserver = $found_server;
703: }
1.141 raeburn 704: if ($otherserver eq '') {
705: my $lowest_load;
706: ($otherserver,undef,undef,undef,$lowest_load) = &Apache::lonnet::choose_server($form{'udom'});
707: if ($lowest_load > 100) {
1.163 raeburn 708: $otherserver = &Apache::lonnet::spareserver($r,$lowest_load,$lowest_load,1,$form{'udom'});
1.141 raeburn 709: }
710: }
711: if ($otherserver ne '') {
712: my @hosts = &Apache::lonnet::current_machine_ids();
713: if (grep(/^\Q$otherserver\E$/,@hosts)) {
714: $hosthere = $otherserver;
715: }
716: }
717: }
1.136 kruse 718: }
719:
1.141 raeburn 720: if (($is_balancer) && (!$hosthere)) {
1.136 kruse 721: if ($otherserver) {
722: &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,
723: \%form);
724: my $switchto = '/adm/switchserver?otherserver='.$otherserver;
725: if (($firsturl) && ($firsturl ne '/adm/switchserver') && ($firsturl ne '/adm/roles')) {
1.168 raeburn 726: $switchto .= '&origurl='.$firsturl;
1.136 kruse 727: }
728: if ($form{'role'}) {
729: $switchto .= '&role='.$form{'role'};
730: }
731: if ($form{'symb'}) {
732: $switchto .= '&symb='.$form{'symb'};
733: }
1.156 raeburn 734: if ($form{'linkprot'}) {
735: $env{'request.linkprot'} = $form{'linkprot'};
1.167 raeburn 736: } elsif ($form{'linkkey'} ne '') {
1.164 raeburn 737: $env{'request.linkkey'} = $form{'linkkey'};
738: }
739: if ($form{'firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {
740: &set_deeplink_login(%form);
1.156 raeburn 741: }
1.136 kruse 742: $r->internal_redirect($switchto);
743: } else {
1.160 raeburn 744: &Apache::loncommon::content_type($r,'text/html');
745: $r->send_http_header;
1.136 kruse 746: $r->print(&noswitch());
747: }
748: return OK;
749: } else {
750: if (!&check_can_host($r,\%form,$authhost)) {
751: my ($otherserver) = &Apache::lonnet::choose_server($form{'udom'});
752: if ($otherserver) {
753: &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,
754: \%form);
755: my $switchto = '/adm/switchserver?otherserver='.$otherserver;
756: if (($firsturl) && ($firsturl ne '/adm/switchserver') && ($firsturl ne '/adm/roles')) {
1.168 raeburn 757: $switchto .= '&origurl='.$firsturl;
1.136 kruse 758: }
759: if ($form{'role'}) {
760: $switchto .= '&role='.$form{'role'};
761: }
762: if ($form{'symb'}) {
763: $switchto .= '&symb='.$form{'symb'};
764: }
1.156 raeburn 765: if ($form{'linkprot'}) {
766: $env{'request.linkprot'} = $form{'linkprot'};
1.167 raeburn 767: } elsif ($form{'linkkey'} ne '') {
1.164 raeburn 768: $env{'request.linkkey'} = $form{'linkkey'};
769: }
770: if ($form{'firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {
771: &set_deeplink_login(%form);
1.156 raeburn 772: }
1.136 kruse 773: $r->internal_redirect($switchto);
774: } else {
1.160 raeburn 775: &Apache::loncommon::content_type($r,'text/html');
776: $r->send_http_header;
1.136 kruse 777: $r->print(&noswitch());
778: }
779: return OK;
780: }
781:
782: # ------------------------------------------------------- Do the load balancing
783:
784: # ---------------------------------------------------------- Determine own load
785: my $loadlim = $r->dir_config('lonLoadLim');
786: my $loadavg;
787: {
788: my $loadfile=Apache::File->new('/proc/loadavg');
789: $loadavg=<$loadfile>;
790: }
791: $loadavg =~ s/\s.*//g;
792: my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
793: my $userloadpercent=&Apache::lonnet::userload();
794:
795: # ---------------------------------------------------------- Are we overloaded?
796: if ((($userloadpercent>100.0)||($loadpercent>100.0))) {
1.163 raeburn 797: my $unloaded=Apache::lonnet::spareserver($r,$loadpercent,$userloadpercent,1,$form{'udom'});
1.136 kruse 798: if (!$unloaded) {
799: ($unloaded) = &Apache::lonnet::choose_server($form{'udom'});
800: }
801: if ($unloaded) {
802: &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',
803: undef,\%form);
1.156 raeburn 804: if ($form{'linkprot'}) {
805: $env{'request.linkprot'} = $form{'linkprot'};
1.167 raeburn 806: } elsif ($form{'linkkey'} ne '') {
1.164 raeburn 807: $env{'request.linkkey'} = $form{'linkkey'};
808: }
809: if ($form{'firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {
810: &set_deeplink_login(%form);
1.156 raeburn 811: }
1.136 kruse 812: $r->internal_redirect('/adm/switchserver?otherserver='.$unloaded.'&origurl='.$firsturl);
813: return OK;
814: }
815: }
1.141 raeburn 816: if (($is_balancer) && ($hosthere)) {
817: $form{'noloadbalance'} = $hosthere;
818: }
1.156 raeburn 819: my $extra_env;
1.169 raeburn 820: if (($hosthere) && ($sessiondata{'sessionserver'} ne '')) {
821: if ($sessiondata{'origurl'} ne '') {
822: $firsturl = $sessiondata{'origurl'};
823: $form{'firsturl'} = $sessiondata{'origurl'};
824: my @names = ('role','symb','linkprot','linkkey');
825: foreach my $item (@names) {
826: if ($sessiondata{$item} ne '') {
827: $form{$item} = $sessiondata{$item};
828: }
829: }
830: }
831: }
1.156 raeburn 832: if ($form{'linkprot'}) {
833: my ($linkprotector,$uri) = split(/:/,$form{'linkprot'},2);
834: if ($linkprotector) {
835: $extra_env = {'user.linkprotector' => $linkprotector,
1.164 raeburn 836: 'user.linkproturi' => $uri};
1.156 raeburn 837: }
1.167 raeburn 838: } elsif ($form{'linkkey'} ne '') {
1.166 raeburn 839: $extra_env = {'user.deeplinkkey' => $form{'linkkey'},
1.164 raeburn 840: 'user.keyedlinkuri' => $form{'firsturl'}};
841: }
842: if ($form{'firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {
843: &set_deeplink_login(%form);
1.166 raeburn 844: if ($form{'linkprot'}) {
845: if (ref($extra_env) eq 'HASH') {
846: %{$extra_env} = ( %{$extra_env}, 'request.linkprot' => $form{'linkprot'} );
847: } else {
848: $extra_env = {'request.linkprot' => $form{'linkprot'}};
849: }
1.167 raeburn 850: } elsif ($form{'linkkey'} ne '') {
1.166 raeburn 851: if (ref($extra_env) eq 'HASH') {
852: %{$extra_env} = ( %{$extra_env}, 'request.linkkey' => $form{'linkkey'} );
853: } else {
854: $extra_env = {'request.linkkey' => $form{'linkkey'}};
855: }
856: }
1.164 raeburn 857: if ($env{'request.deeplink.login'}) {
858: if (ref($extra_env) eq 'HASH') {
859: %{$extra_env} = ( %{$extra_env}, 'request.deeplink.login' => $form{'firsturl'} );
860: } else {
861: $extra_env = {'request.deeplink.login' => $form{'firsturl'}};
862: }
1.157 raeburn 863: }
1.156 raeburn 864: }
865: &success($r,$form{'uname'},$form{'udom'},$authhost,$firsturl,$extra_env,
1.136 kruse 866: \%form);
867: return OK;
868: }
869: }
870:
1.169 raeburn 871: sub get_form_items {
872: my ($r) = @_;
873: my $buffer;
874: if ($r->header_in('Content-length') > 0) {
875: $r->read($buffer,$r->header_in('Content-length'),0);
876: }
877: my %form;
878: foreach my $pair (split(/&/,$buffer)) {
879: my ($name,$value) = split(/=/,$pair);
880: $value =~ tr/+/ /;
881: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
882: $form{$name}=$value;
883: }
884: return %form;
885: }
886:
1.164 raeburn 887: sub set_deeplink_login {
888: my (%form) = @_;
1.169 raeburn 889: my $disallow;
1.164 raeburn 890: if ($form{'firsturl'} =~ m{^/tiny/($match_domain)/\w+$}) {
891: my $cdom = $1;
892: my ($cnum,$symb) = &Apache::loncommon::symb_from_tinyurl($form{'firsturl'},'',$cdom);
893: if ($symb) {
1.166 raeburn 894: if ($env{'request.course.id'} eq $cdom.'_'.$cnum) {
1.169 raeburn 895: my $deeplink;
1.166 raeburn 896: if ($symb =~ /\.(page|sequence)$/) {
897: my $mapname = &Apache::lonnet::deversion((&Apache::lonnet::decode_symb($symb))[2]);
898: my $navmap = Apache::lonnavmaps::navmap->new();
899: if (ref($navmap)) {
900: $deeplink = $navmap->get_mapparam(undef,$mapname,'0.deeplink');
901: }
902: } else {
903: $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$symb);
904: }
905: if ($deeplink ne '') {
906: my ($state,$others,$listed,$scope,$protect) = split(/,/,$deeplink);
907: if (($protect ne 'none') && ($protect ne '')) {
908: my ($acctype,$item) = split(/:/,$protect);
909: if ($acctype =~ /lti(c|d)$/) {
910: unless ($form{'linkprot'} eq $item.$1.':'.$env{'request.deeplink.login'}) {
911: $disallow = 1;
912: }
913: } elsif ($acctype eq 'key') {
914: unless ($form{'linkkey'} eq $item) {
915: $disallow = 1;
916: }
1.164 raeburn 917: }
918: }
919: }
1.166 raeburn 920: unless ($disallow) {
921: $env{'request.deeplink.login'} = $form{'firsturl'};
922: }
923: } else {
1.164 raeburn 924: $env{'request.deeplink.login'} = $form{'firsturl'};
925: }
926: }
927: }
1.169 raeburn 928: if ($disallow) {
929: return;
930: }
931: return 'ok';
1.164 raeburn 932: }
933:
1.168 raeburn 934: sub set_retry_token {
935: my ($form,$lonhost,$querystr) = @_;
936: if (ref($form) eq 'HASH') {
937: my ($firsturl,$token,$extras,@names);
1.169 raeburn 938: @names = ('role','symb','linkprot','linkkey','iptoken');
1.168 raeburn 939: foreach my $name (@names) {
940: if ($form->{$name} ne '') {
941: $extras .= '&'.$name.'='.&escape($form->{$name});
942: last if ($name eq 'linkprot');
943: }
944: }
945: my $firsturl = $form->{'firsturl'};
946: if (($firsturl ne '') || ($extras ne '')) {
947: $extras .= ':retry';
948: $token = &Apache::lonnet::reply('tmpput:'.&escape($firsturl).
949: $extras,$lonhost);
950: if (($token eq 'con_lost') || ($token eq 'no_such_host')) {
951: return 'fail';
952: } else {
953: if (ref($querystr)) {
954: $$querystr = 'retry='.$token;
955: }
956: return 'ok';
957: }
958: }
959: }
960: return;
961: }
962:
1.136 kruse 963: sub check_can_host {
964: my ($r,$form,$authhost,$domdesc) = @_;
965: return unless (ref($form) eq 'HASH');
966: my $canhost = 1;
967: my $lonhost = $r->dir_config('lonHostID');
968: my $udom = $form->{'udom'};
969: my @intdoms;
970: my $internet_names = &Apache::lonnet::get_internet_names($lonhost);
971: if (ref($internet_names) eq 'ARRAY') {
972: @intdoms = @{$internet_names};
973: }
974: my $uprimary_id = &Apache::lonnet::domain($udom,'primary');
975: my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);
976: unless ($uint_dom ne '' && grep(/^\Q$uint_dom\E$/,@intdoms)) {
977: my $machine_dom = &Apache::lonnet::host_domain($lonhost);
978: my $hostname = &Apache::lonnet::hostname($lonhost);
979: my $serverhomeID = &Apache::lonnet::get_server_homeID($hostname);
980: my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID);
981: my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom);
982: my %udomdefaults = &Apache::lonnet::get_domain_defaults($udom);
983: my $loncaparev;
984: if ($authhost eq 'no_account_on_host') {
985: $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom);
986: } else {
987: $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom,$lonhost);
988: }
989: $canhost = &Apache::lonnet::can_host_session($udom,$lonhost,$loncaparev,
990: $udomdefaults{'remotesessions'},
991: $defdomdefaults{'hostedsessions'});
992: }
993: unless ($canhost) {
994: if ($authhost eq 'no_account_on_host') {
995: my $checkloginvia = 1;
996: my ($login_host,$hostname) =
997: &Apache::lonnet::choose_server($udom,$checkloginvia);
998: &Apache::loncommon::content_type($r,'text/html');
999: $r->send_http_header;
1000: if ($login_host ne '') {
1001: my $protocol = $Apache::lonnet::protocol{$login_host};
1002: $protocol = 'http' if ($protocol ne 'https');
1.163 raeburn 1003: my $alias = &Apache::lonnet::use_proxy_alias($r,$login_host);
1004: $hostname = $alias if ($alias ne '');
1.136 kruse 1005: my $newurl = $protocol.'://'.$hostname.'/adm/createaccount';
1.156 raeburn 1006: #FIXME Should preserve where user was going and linkprot by setting ltoken at $login_host
1.136 kruse 1007: $r->print(&Apache::loncommon::start_page('Create a user account in LON-CAPA').
1008: '<h3>'.&mt('Account creation').'</h3>'.
1009: &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.
1010: '<p>'.&mt('You will be able to create one by logging into a LON-CAPA server within the [_1] domain.',$domdesc).'</p>'.
1011: '<p>'.&mt('[_1]Log in[_2]','<a href="'.$newurl.'">','</a>').
1012: &Apache::loncommon::end_page());
1013: } else {
1014: $r->print(&Apache::loncommon::start_page('Access to LON-CAPA unavailable').
1015: '<h3>'.&mt('Account creation unavailable').'</h3>'.
1016: &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.
1017: '<p>'.&mt('Currently a LON-CAPA server is not available within the [_1] domain for you to log-in to, to create an account.',$domdesc).'</p>'.
1018: &Apache::loncommon::end_page());
1019: }
1020: } else {
1021: &success($r,$form->{'uname'},$udom,$authhost,'noredirect',undef,
1022: $form);
1.168 raeburn 1023: if ($form->{'firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {
1024: $env{'request.deeplink.login'} = $form->{'firsturl'};
1025: }
1.156 raeburn 1026: if ($form->{'linkprot'}) {
1027: $env{'request.linkprot'} = $form->{'linkprot'};
1.168 raeburn 1028: } elsif ($form->{'linkkey'} ne '') {
1029: $env{'request.linkkey'} = $form->{'linkkey'};
1.156 raeburn 1030: }
1.136 kruse 1031: my ($otherserver) = &Apache::lonnet::choose_server($udom);
1032: $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver);
1033: }
1034: }
1035: return $canhost;
1036: }
1037:
1038: sub noswitch {
1039: my $result = &Apache::loncommon::start_page('Access to LON-CAPA unavailable').
1040: '<h3>'.&mt('Session unavailable').'</h3>'.
1041: &mt('This LON-CAPA server is unable to host your session.').'<br />'.
1042: '<p>'.&mt('Currently no other LON-CAPA server is available to host your session either.').'</p>'.
1043: &Apache::loncommon::end_page();
1044: return $result;
1045: }
1046:
1047: sub loginhelpdisplay {
1048: my ($authdomain) = @_;
1049: my $login_help = 1;
1050: my $lang = &Apache::lonlocal::current_language();
1051: if ($login_help) {
1052: my $dom = $authdomain;
1053: if ($dom eq '') {
1054: $dom = &Apache::lonnet::default_login_domain();
1055: }
1056: my %domconfhash = &Apache::loncommon::get_domainconf($dom);
1057: my $loginhelp_url;
1058: if ($lang) {
1059: $loginhelp_url = $domconfhash{$dom.'.login.helpurl_'.$lang};
1060: if ($loginhelp_url ne '') {
1061: return $loginhelp_url;
1062: }
1063: }
1064: $loginhelp_url = $domconfhash{$dom.'.login.helpurl_nolang'};
1065: if ($loginhelp_url ne '') {
1066: return $loginhelp_url;
1067: } else {
1068: return '/adm/loginproblems.html';
1069: }
1070: }
1071: return;
1072: }
1073:
1074: 1;
1075: __END__
1076:
1077:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>