--- loncom/interface/loncreateuser.pm 2007/12/31 02:28:12 1.226 +++ loncom/interface/loncreateuser.pm 2008/01/01 17:24:59 1.227 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.226 2007/12/31 02:28:12 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.227 2008/01/01 17:24:59 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -76,30 +76,30 @@ my $authformfsys; my $authformloc; sub initialize_authen_forms { - my ($dom,$curr_authtype,$mode) = @_; - my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/); - $krbdefdom= uc($krbdefdom); - my %param = ( formname => 'document.cu', + my ($dom,$formname,$curr_authtype,$mode) = @_; + my ($krbdef,$krbdefdom) = &Apache::loncommon::get_kerberos_defaults($dom); + my %param = ( formname => $formname, kerb_def_dom => $krbdefdom, + kerb_def_auth => $krbdef, domain => $dom, ); my %abv_auth = &auth_abbrev(); - if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):$/) { + if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):(.*)$/) { my $long_auth = $1; + my $curr_autharg = $2; my %abv_auth = &auth_abbrev(); $param{'curr_authtype'} = $abv_auth{$long_auth}; if ($long_auth =~ /^krb(4|5)$/) { $param{'curr_kerb_ver'} = $1; + $param{'curr_autharg'} = $curr_autharg; } if ($mode eq 'modifyuser') { $param{'mode'} = $mode; } } -# no longer static due to configurable kerberos defaults -# $loginscript = &Apache::loncommon::authform_header(%param); + $loginscript = &Apache::loncommon::authform_header(%param); + $authformkrb = &Apache::loncommon::authform_kerberos(%param); $authformnop = &Apache::loncommon::authform_nochange(%param); -# no longer static due to configurable kerberos defaults -# $authformkrb = &Apache::loncommon::authform_kerberos(%param); $authformint = &Apache::loncommon::authform_internal(%param); $authformfsys = &Apache::loncommon::authform_filesystem(%param); $authformloc = &Apache::loncommon::authform_local(%param); @@ -515,8 +515,7 @@ sub print_user_modification_page { $formname = 'cu'; } my %abv_auth = &auth_abbrev(); - my ($curr_authtype,%rulematch,%inst_results,$curr_kerb_ver,$newuser, - %alerts,%curr_rules,%got_rules); + my (%rulematch,%inst_results,$newuser,%alerts,%curr_rules,%got_rules); my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); if ($uhome eq 'no_host') { my $usertype; @@ -571,32 +570,10 @@ sub print_user_modification_page { } } else { $newuser = 0; - my $currentauth = - &Apache::lonnet::queryauthenticate($ccuname,$ccdomain); - if ($currentauth =~ /^(krb4|krb5|unix|internal|localauth):/) { - $curr_authtype = $abv_auth{$1}; - if ($currentauth =~ /^krb(4|5)/) { - $curr_kerb_ver = $1; - } - } } if ($response) { $response = '
'.$response; } - my $defdom=$env{'request.role.domain'}; - - my ($krbdef,$krbdefdom) = - &Apache::loncommon::get_kerberos_defaults($defdom); - - my %param = ( formname => 'document.cu', - kerb_def_dom => $krbdefdom, - kerb_def_auth => $krbdef, - curr_authtype => $curr_authtype, - curr_kerb_ver => $curr_kerb_ver, - domain => $ccdomain, - ); - $loginscript = &Apache::loncommon::authform_header(%param); - $authformkrb = &Apache::loncommon::authform_kerberos(%param); my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); my $dc_setcourse_code = ''; @@ -654,7 +631,7 @@ ENDFORMINFO # Current user has quota modification privileges $portfolioform = '
'.&portfolio_quota($ccuname,$ccdomain); } - &initialize_authen_forms($ccdomain); + &initialize_authen_forms($ccdomain,$formname); my %lt=&Apache::lonlocal::texthash( 'cnu' => 'Create New User', 'ast' => 'as a student', @@ -775,8 +752,7 @@ ENDCHANGEUSER $r->print(&Apache::lonuserutils::forceid_change($context)); } $r->print(''); - my $user_auth_text = - &user_authentication($ccuname,$ccdomain,$krbdefdom,\%abv_auth); + my $user_auth_text = &user_authentication($ccuname,$ccdomain,$formname); my $user_quota_text; if (&Apache::lonnet::allowed('mpq',$ccdomain)) { # Current user has quota modification privileges @@ -840,7 +816,7 @@ ENDNOPORTPRIV if ($addrolesdisplay) { $r->print('
print(' onClick="verify_message(this.form)" \>'."\n"); + $r->print(' onClick="auth_check()" \>'."\n"); } else { $r->print('onClick="this.form.submit()" \>'."\n"); } @@ -897,26 +873,28 @@ sub validation_javascript { if ($context eq 'domain') { my $dcdom = $env{'request.role.domain'}; $loaditem->{'onload'} = "document.cu.coursedesc.value='';"; - $dc_setcourse_code = &Apache::lonuserutils::dc_setcourse_js('cu','singleuser'); + $dc_setcourse_code = + &Apache::lonuserutils::dc_setcourse_js('cu','singleuser',$context); } else { - $nondc_setsection_code = - &Apache::lonuserutils::setsections_javascript($formname,$groupslist); + my $checkauth; + if (($newuser) || (&Apache::lonnet::allowed('mau',$ccdomain))) { + $checkauth = 1; + } + if ($context eq 'course') { + $nondc_setsection_code = + &Apache::lonuserutils::setsections_javascript($formname,$groupslist, + undef,$checkauth); + } + if ($checkauth) { + $nondc_setsection_code .= + &Apache::lonuserutils::verify_authen($formname,$context); + } } my $js = &user_modification_js($pjump_def,$dc_setcourse_code, $nondc_setsection_code,$groupslist); - my ($jsback,$elements) = &crumb_utilities(); - my $javascript_validations; - if ((&Apache::lonnet::allowed('mau',$ccdomain)) || ($newuser)) { - my ($krbdef,$krbdefdom) = - &Apache::loncommon::get_kerberos_defaults($ccdomain); - $javascript_validations = - &Apache::lonuserutils::javascript_validations('createuser',$krbdefdom,undef, - undef,$ccdomain); - } $js .= "\n". - ''; + ''; return $js; } @@ -1241,22 +1219,9 @@ sub new_domain_roles { } sub user_authentication { - my ($ccuname,$ccdomain,$krbdefdom,$abv_auth) = @_; + my ($ccuname,$ccdomain,$formname) = @_; my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); - my ($loginscript,$outcome); - if ($currentauth=~/^(krb)(4|5):(.*)/) { - my $long_auth = $1.$2; - my $curr_kerb_ver = $2; - my $krbdefdom=$3; - my $curr_authtype = $abv_auth->{$long_auth}; - my %param = ( formname => 'document.cu', - kerb_def_dom => $krbdefdom, - domain => $ccdomain, - curr_authtype => $curr_authtype, - curr_kerb_ver => $curr_kerb_ver, - ); - $loginscript = &Apache::loncommon::authform_header(%param); - } + my $outcome; # Check for a bad authentication type if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) { # bad authentication scheme @@ -1268,7 +1233,8 @@ sub user_authentication { 'ld' => "Login Data" ); if (&Apache::lonnet::allowed('mau',$ccdomain)) { - &initialize_authen_forms($ccdomain); + &initialize_authen_forms($ccdomain,$formname); + my $choices = &Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc); $outcome = < @@ -1289,7 +1255,7 @@ $lt{'uuas'} ($currentauth). $lt{'adcs'}. ENDBADAUTH } } else { # Authentication type is valid - &initialize_authen_forms($ccdomain,$currentauth,'modifyuser'); + &initialize_authen_forms($ccdomain,$formname,$currentauth,'modifyuser'); my ($authformcurrent,$can_modify,@authform_others) = &modify_login_block($ccdomain,$currentauth); if (&Apache::lonnet::allowed('mau',$ccdomain)) {