Annotation of loncom/interface/loncreateuser.pm, revision 1.20
1.20 ! harris41 1: # The LearningOnline Network with CAPA
1.1 www 2: # Create a user
3: #
4: # (Create a course
5: # (My Desk
6: #
7: # (Internal Server Error Handler
8: #
9: # (Login Screen
10: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
11: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
12: #
1.20 ! harris41 13: # YEAR=2001
1.1 www 14: # 3/1/1 Gerd Kortemeyer)
15: #
16: # 3/1 Gerd Kortemeyer)
17: #
18: # 2/14 Gerd Kortemeyer)
19: #
1.12 www 20: # 2/14,2/17,2/19,2/20,2/21,2/22,2/23,3/2,3/17,3/24,04/12 Gerd Kortemeyer
1.17 www 21: # April Guy Albertelli
1.19 www 22: # 05/10,10/16 Gerd Kortemeyer
1.20 ! harris41 23: # 11/12,11/13,11/15 Scott Harrison
1.1 www 24: #
1.20 ! harris41 25: # $Id: loncreateuser,v 1.19 2001/10/16 21:16:01 www Exp $
! 26: ###
! 27:
1.1 www 28: package Apache::loncreateuser;
29:
30: use strict;
31: use Apache::Constants qw(:common :http);
32: use Apache::lonnet;
33:
1.20 ! harris41 34: my $loginscript; # piece of javascript used in two separate instances
! 35: my $generalrule;
! 36: my $authformnop;
! 37: my $authformkrb;
! 38: my $authformint;
! 39: my $authformfsys;
! 40: my $authformloc;
! 41:
! 42: sub BEGIN {
! 43: $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
! 44: my $krbdefdom=$1;
! 45: $krbdefdom=~tr/a-z/A-Z/;
! 46: $authformnop=(<<END);
! 47: <p>
! 48: <input type=radio name=login value=nop checked='checked'
! 49: onClick="clicknop(this.form);">
! 50: Do not change login data
! 51: </p>
! 52: END
! 53: $authformkrb=(<<END);
! 54: <p>
! 55: <input type=radio name=login value=krb onClick="clickkrb(this.form);">
! 56: Kerberos authenticated with domain
! 57: <input type=text size=10 name=krbdom onChange="setkrb(this.form);">
! 58: </p>
! 59: END
! 60: $authformint=(<<END);
! 61: <p>
! 62: <input type=radio name=login value=int onClick="clickint(this.form);">
! 63: Internally authenticated (with initial password
! 64: <input type=text size=10 name=intpwd onChange="setint(this.form);">)
! 65: </p>
! 66: END
! 67: $authformfsys=(<<END);
! 68: <p>
! 69: <input type=radio name=login value=fsys onClick="clickfsys(this.form);">
! 70: Filesystem authenticated (with initial password
! 71: <input type=text size=10 name=fsyspwd onChange="setfsys(this.form);">)
! 72: </p>
! 73: END
! 74: $authformloc=(<<END);
! 75: <p>
! 76: <input type=radio name=login value=loc onClick="clickloc(this.form);" />
! 77: Local Authentication with argument
! 78: <input type=text size=10 name=locarg onChange="setloc(this.form);" />
! 79: </p>
! 80: END
! 81: $loginscript=(<<ENDLOGINSCRIPT);
! 82: <script>
! 83: function setkrb(vf) {
! 84: if (vf.krbdom.value!='') {
! 85: vf.login[0].checked=true;
! 86: vf.krbdom.value=vf.krbdom.value.toUpperCase();
! 87: vf.intpwd.value='';
! 88: vf.fsyspwd.value='';
! 89: vf.locarg.value='';
! 90: }
! 91: }
! 92:
! 93: function setint(vf) {
! 94: if (vf.intpwd.value!='') {
! 95: vf.login[1].checked=true;
! 96: vf.krbdom.value='';
! 97: vf.fsyspwd.value='';
! 98: vf.locarg.value='';
! 99: }
! 100: }
! 101:
! 102: function setfsys(vf) {
! 103: if (vf.fsyspwd.value!='') {
! 104: vf.login[2].checked=true;
! 105: vf.krbdom.value='';
! 106: vf.intpwd.value='';
! 107: vf.locarg.value='';
! 108: }
! 109: }
! 110:
! 111: function setloc(vf) {
! 112: if (vf.locarg.value!='') {
! 113: vf.login[3].checked=true;
! 114: vf.krbdom.value='';
! 115: vf.intpwd.value='';
! 116: vf.fsyspwd.value='';
! 117: }
! 118: }
! 119:
! 120: function clicknop(vf) {
! 121: vf.krbdom.value='';
! 122: vf.intpwd.value='';
! 123: vf.fsyspwd.value='';
! 124: vf.locarg.value='';
! 125: }
! 126:
! 127: function clickkrb(vf) {
! 128: vf.krbdom.value='$krbdefdom';
! 129: vf.intpwd.value='';
! 130: vf.fsyspwd.value='';
! 131: vf.locarg.value='';
! 132: }
! 133:
! 134: function clickint(vf) {
! 135: vf.krbdom.value='';
! 136: vf.fsyspwd.value='';
! 137: vf.locarg.value='';
! 138: }
! 139:
! 140: function clickfsys(vf) {
! 141: vf.krbdom.value='';
! 142: vf.intpwd.value='';
! 143: vf.locarg.value='';
! 144: }
! 145:
! 146: function clickloc(vf) {
! 147: vf.krbdom.value='';
! 148: vf.intpwd.value='';
! 149: vf.fsyspwd.value='';
! 150: }
! 151: </script>
! 152: ENDLOGINSCRIPT
! 153: $generalrule=<<END;
! 154: <p>
! 155: <i>As a general rule, only authors or co-authors should be filesystem
! 156: authenticated (which allows access to the server filesystem).</i>
! 157: </p>
! 158: END
! 159: }
! 160:
1.2 www 161: # =================================================================== Phase one
1.1 www 162:
1.2 www 163: sub phase_one {
164: my $r=shift;
165: my $defdom=$ENV{'user.domain'};
1.1 www 166: $r->print(<<ENDDOCUMENT);
167: <html>
168: <head>
169: <title>The LearningOnline Network with CAPA</title>
170: </head>
171: <body bgcolor="#FFFFFF">
172: <h1>Create User, Change User Privileges</h1>
1.2 www 173: <form action=/adm/createuser method=post>
174: <input type=hidden name=phase value=two>
175: Username: <input type=text size=15 name=ccuname><br>
176: Domain: <input type=text size=15 name=ccdomain value=$defdom><p>
177: <input type=submit value="Continue">
178: </form>
1.1 www 179: </body>
180: </html>
181: ENDDOCUMENT
1.2 www 182: }
183:
184: # =================================================================== Phase two
185:
186: sub phase_two {
187: my $r=shift;
188: my $ccuname=$ENV{'form.ccuname'};
189: my $ccdomain=$ENV{'form.ccdomain'};
1.4 www 190:
191: $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
192: my $krbdefdom=$1;
193: $krbdefdom=~tr/a-z/A-Z/;
194:
195: my $defdom=$ENV{'user.domain'};
196:
1.2 www 197: $ccuname=~s/\W//g;
198: $ccdomain=~s/\W//g;
199: $r->print(<<ENDENHEAD);
200: <html>
201: <head>
202: <title>The LearningOnline Network with CAPA</title>
1.3 www 203: <script>
204:
205: function pclose() {
206: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
207: "height=350,width=350,scrollbars=no,menubar=no");
208: parmwin.close();
209: }
210:
211: function pjump(type,dis,value,marker,ret,call) {
212: parmwin=window.open("/adm/rat/parameter.html?type="+escape(type)
213: +"&value="+escape(value)+"&marker="+escape(marker)
214: +"&return="+escape(ret)
215: +"&call="+escape(call)+"&name="+escape(dis),"LONCAPAparms",
216: "height=350,width=350,scrollbars=no,menubar=no");
217:
218: }
219:
220: function dateset() {
221: eval("document.cu."+document.cu.pres_marker.value+
222: ".value=document.cu.pres_value.value");
223: pclose();
224: }
225:
226: </script>
1.2 www 227: </head>
228: <body bgcolor="#FFFFFF">
229: <img align=right src=/adm/lonIcons/lonlogos.gif>
230: <h1>Create User, Change User Privileges</h1>
1.3 www 231: <form action=/adm/createuser method=post name=cu>
1.2 www 232: <input type=hidden name=phase value=three>
233: <input type=hidden name=ccuname value=$ccuname>
234: <input type=hidden name=ccdomain value=$ccdomain>
1.3 www 235: <input type="hidden" value='' name="pres_value">
236: <input type="hidden" value='' name="pres_type">
237: <input type="hidden" value='' name="pres_marker">
1.6 www 238: <input type=hidden name=cuname value="$ccuname">
239: <input type=hidden name=cdomain value="$ccdomain">
1.3 www 240:
1.2 www 241: ENDENHEAD
242: my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
243: my %incdomains;
244: my %inccourses;
1.13 www 245: map {
246: $incdomains{$_}=1;
1.16 albertel 247: } values %Apache::lonnet::hostdom;
1.2 www 248: map {
249: if ($_=~/^user\.priv\.cm\.\/(\w+)\/(\w+)/) {
250: $inccourses{$1.'_'.$2}=1;
251: }
252: } %ENV;
253: if ($uhome eq 'no_host') {
1.4 www 254: $r->print(<<ENDNUSER);
1.6 www 255: <h2>New user $ccuname at $ccdomain</h2>
1.20 ! harris41 256: ENDNUSER
! 257: $r->print(<<ENDNUSER);
! 258: $loginscript
! 259: <input type='hidden' name='makeuser' value='1' />
1.4 www 260: <h3>Personal Data</h3>
1.20 ! harris41 261: First Name: <input type='text' name='cfirst' size='15' /><br />
! 262: Middle Name: <input type='text' name='cmiddle' size='15' /><br />
! 263: Last Name: <input type='text' name='clast' size='15' /><br />
! 264: Generation: <input type='text' name='cgen' size='5' /><p>
1.4 www 265:
1.20 ! harris41 266: ID/Student Number: <input type='text' name='cstid' size='10' /></p>
1.4 www 267:
268: <h3>Login Data</h3>
1.20 ! harris41 269: $generalrule
! 270: $authformkrb
! 271: $authformint
! 272: $authformfsys
! 273: $authformloc
1.4 www 274: ENDNUSER
1.2 www 275: } else {
1.6 www 276: $r->print('<h2>Existing user '.$ccuname.' at '.$ccdomain.'</h2>');
1.5 www 277:
1.2 www 278: my $rolesdump=&Apache::lonnet::reply(
279: "dump:$ccdomain:$ccuname:roles",$uhome);
280: unless ($rolesdump eq 'con_lost') {
281: my $now=time;
282: $r->print('<h4>Revoke Existing Roles</h4>'.
283: '<table border=2><tr><th>Revoke</th><th>Role</th><th>Extent</th>'.
284: '<th>Start</th><th>End</th>');
285: map {
286: if ($_!~/^rolesdef\&/) {
287:
288: my ($area,$role)=split(/=/,$_);
289: my $thisrole=$area;
290: $area=~s/\_\w\w$//;
291: my ($trole,$tend,$tstart)=split(/_/,$role);
1.3 www 292: my $bgcol='ffffff';
1.2 www 293: my $allows=0;
1.5 www 294: if ($area=~/^\/(\w+)\/(\d\w+)/) {
1.2 www 295: my %coursedata=&Apache::lonnet::coursedescription($1.'_'.$2);
1.5 www 296: my $carea='Course: '.$coursedata{'description'};
1.2 www 297: $inccourses{$1.'_'.$2}=1;
1.7 www 298: if (&Apache::lonnet::allowed('c'.$trole,$1.'/'.$2)) {
1.2 www 299: $allows=1;
300: }
1.3 www 301: $bgcol=$1.'_'.$2;
302: $bgcol=~s/[^8-9b-e]//g;
303: $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',0,6);
1.5 www 304: if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) {
305: $carea.='<br>Section/Group: '.$3;
306: }
307: $area=$carea;
1.2 www 308: } else {
1.7 www 309: if ($area=~/^\/(\w+)\//) {
1.2 www 310: if (&Apache::lonnet::allowed('c'.$trole,$1)) {
1.7 www 311: $allows=1;
312: }
313: } else {
314: if (&Apache::lonnet::allowed('c'.$trole,'/')) {
1.2 www 315: $allows=1;
316: }
317: }
318: }
319:
320: my $active=1;
321: if (($tend) && ($now>$tend)) { $active=0; }
322:
1.3 www 323: $r->print('<tr bgcolor=#'.$bgcol.'><td>');
1.2 www 324: if ($active) {
325: if ($allows) {
326: $r->print(
327: '<input type=checkbox name="rev:'.$thisrole.'">');
328: } else {
329: $r->print(' ');
330: }
331: } else {
332: $r->print(' ');
333: }
334: $r->print('</td><td>'.&Apache::lonnet::plaintext($trole).
335: '</td><td>'.$area.'</td><td>'.
336: ($tstart?localtime($tstart):' ').'</td><td>'.
337: ($tend?localtime($tend):' ')."</td></tr>\n");
338: }
339: } split(/&/,$rolesdump);
340: $r->print('</table>');
341: }
1.20 ! harris41 342: my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
! 343: if ($currentauth=~/^krb4:/) {
! 344: $currentauth=~/^krb4:(.*)/;
! 345: my $krbdefdom2=$1;
! 346: $loginscript=~s/vf\.krbdom\.value='.*?';/vf.krbdom.value='$krbdefdom2';/;
! 347: }
! 348: # minor script hack here
! 349: $loginscript=~s/login\[3\]/login\[4\]/;
! 350: $loginscript=~s/login\[2\]/login\[3\]/;
! 351: $loginscript=~s/login\[1\]/login\[2\]/;
! 352: $loginscript=~s/login\[0\]/login\[1\]/;
! 353:
! 354: $r->print(<<END);
! 355: <hr />
! 356: $loginscript
! 357: END
! 358: unless ($currentauth=~/^krb4:/ or
! 359: $currentauth=~/^unix:/ or
! 360: $currentauth=~/^internal:/ or
! 361: $currentauth=~/^localauth:/
! 362: ) {
! 363: $r->print(<<END);
! 364: <font color='#ff0000'>ERROR:</font>
! 365: This user has an unrecognized authentication scheme ($currentauth).
! 366: Please specify login data below.
! 367: <h3>Login Data</h3>
! 368: $generalrule
! 369: $authformkrb
! 370: $authformint
! 371: $authformfsys
! 372: $authformloc
! 373: END
! 374: }
! 375: else {
! 376: my $authformcurrent='';
! 377: my $authformother='';
! 378: if ($currentauth=~/^krb4:/) {
! 379: $authformcurrent=$authformkrb;
! 380: $authformother=$authformint.$authformfsys.$authformloc;
! 381: }
! 382: elsif ($currentauth=~/^internal:/) {
! 383: $authformcurrent=$authformint;
! 384: $authformother=$authformkrb.$authformfsys.$authformloc;
! 385: }
! 386: elsif ($currentauth=~/^unix:/) {
! 387: $authformcurrent=$authformfsys;
! 388: $authformother=$authformkrb.$authformint.$authformloc;
! 389: }
! 390: elsif ($currentauth=~/^localauth:/) {
! 391: $authformcurrent=$authformloc;
! 392: $authformother=$authformkrb.$authformint.$authformfsys;
! 393: }
! 394: $authformcurrent=<<END;
! 395: <table border='1'>
! 396: <tr>
! 397: <td><font color='#ff0000'>* * * WARNING * * *</font></td>
! 398: <td><font color='#ff0000'>* * * WARNING * * *</font></td>
! 399: </tr>
! 400: <tr><td bgcolor='#cbbcbb'>$authformcurrent</td>
! 401: <td bgcolor='#cbbcbb'>Changing this value will overwrite existing authentication for the user; you should notify the user of this change.</td></tr>
! 402: </table>
! 403: END
! 404: $r->print(<<END);
! 405: <h3>Change Current Login Data</h3>
! 406: $generalrule
! 407: $authformnop
! 408: $authformcurrent
! 409: <h3>Enter New Login Data</h3>
! 410: $authformother
! 411: END
! 412: }
1.2 www 413: }
1.20 ! harris41 414: $r->print('<hr /><h3>Add Roles</h3>');
1.17 www 415: #
416: # Co-Author
417: #
418:
419: if (&Apache::lonnet::allowed('cca',$ENV{'user.domain'})) {
420: my $cuname=$ENV{'user.name'};
421: my $cudom=$ENV{'user.domain'};
422: $r->print(<<ENDCOAUTH);
423: <h4>Construction Space</h4>
424: <table border=2><tr><th>Activate</th><th>Role</th><th>Extent</th>
425: <th>Start</th><th>End</th></tr>
426: <tr>
427: <td><input type=checkbox name="act_$cudom\_$cuname\_ca"></td>
428: <td>Co-Author</td>
429: <td>$cudom\_$cuname</td>
430: <td><input type=hidden name="start_$cudom\_$cuname\_ca" value=''>
431: <a href=
432: "javascript:pjump('date_start','Start Date Co-Author',document.cu.start_$cudom\_$cuname\_ca.value,'start_$cudom\_$cuname\_ca','cu.pres','dateset')">Set Start Date</a></td>
433: <td><input type=hidden name="end_$cudom\_$cuname\_ca" value=''>
434: <a href=
435: "javascript:pjump('date_end','End Date Co-Author',document.cu.end_$cudom\_$cuname\_ca.value,'end_$cudom\_$cuname\_ca','cu.pres','dateset')">Set End Date</a></td>
436: </tr>
437: </table>
438: ENDCOAUTH
439: }
1.8 www 440: #
441: # Domain level
442: #
443: $r->print('<h4>Domain Level</h4>'.
444: '<table border=2><tr><th>Activate</th><th>Role</th><th>Extent</th>'.
445: '<th>Start</th><th>End</th></tr>');
1.2 www 446: map {
447: my $thisdomain=$_;
448: map {
449: if (&Apache::lonnet::allowed('c'.$_,$thisdomain)) {
1.8 www 450: my $plrole=&Apache::lonnet::plaintext($_);
451: $r->print(<<ENDDROW);
452: <tr>
453: <td><input type=checkbox name="act_$thisdomain\_$_"></td>
454: <td>$plrole</td>
455: <td>$thisdomain</td>
456: <td><input type=hidden name="start_$thisdomain\_$_" value=''>
457: <a href=
458: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$thisdomain\_$_.value,'start_$thisdomain\_$_','cu.pres','dateset')">Set Start Date</a></td>
459: <td><input type=hidden name="end_$thisdomain\_$_" value=''>
460: <a href=
461: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$thisdomain\_$_.value,'end_$thisdomain\_$_','cu.pres','dateset')">Set End Date</a></td>
462: </tr>
463: ENDDROW
1.2 www 464: }
1.12 www 465: } ('dc','li','dg','au');
1.2 www 466: } sort keys %incdomains;
1.8 www 467: $r->print('</table>');
468: #
469: # Course level
470: #
1.6 www 471: $r->print('<h4>Course Level</h4>'.
1.3 www 472: '<table border=2><tr><th>Activate</th><th>Role</th><th>Extent</th>'.
473: '<th>Group/Section</th><th>Start</th><th>End</th></tr>');
1.2 www 474: map {
475: my $thiscourse=$_;
1.15 albertel 476: my $protectedcourse=$_;
477: $thiscourse=~s:_:/:g;
1.3 www 478: my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
479: my $area=$coursedata{'description'};
480: my $bgcol=$thiscourse;
481: $bgcol=~s/[^8-9b-e]//g;
482: $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',0,6);
1.2 www 483: map {
484: if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) {
1.3 www 485: my $plrole=&Apache::lonnet::plaintext($_);
1.16 albertel 486: $r->print("
1.3 www 487: <tr bgcolor=#$bgcol>
1.16 albertel 488: <td><input type=checkbox name=\"act_$protectedcourse\_$_\"></td>
1.3 www 489: <td>$plrole</td>
490: <td>$area</td>
1.16 albertel 491: <td>");
492: if ($_ ne 'cc') {
493: $r->print("<input type=text size=5 name=\"sec_$protectedcourse\_$_\">");
494: } else { $r->print(" "); }
495: $r->print(<<ENDROW);
1.15 albertel 496: <td><input type=hidden name="start_$protectedcourse\_$_" value=''>
1.3 www 497: <a href=
1.15 albertel 498: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$_.value,'start_$protectedcourse\_$_','cu.pres','dateset')">Set Start Date</a></td>
499: <td><input type=hidden name="end_$protectedcourse\_$_" value=''>
1.3 www 500: <a href=
1.15 albertel 501: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$_.value,'end_$protectedcourse\_$_','cu.pres','dateset')">Set End Date</a></td>
1.3 www 502: </tr>
503: ENDROW
1.2 www 504: }
1.12 www 505: } ('st','ta','ep','ad','in','cc');
1.2 www 506: } sort keys %inccourses;
1.3 www 507: $r->print('</table>');
1.6 www 508: $r->print('<input type=submit value="Modify User">');
1.2 www 509: $r->print('</form></body></html>');
510: }
1.1 www 511:
1.4 www 512: # ================================================================= Phase Three
513:
514: sub phase_three {
515: my $r=shift;
516: $r->print(<<ENDTHREEHEAD);
517: <html>
518: <head>
519: <title>The LearningOnline Network with CAPA</title>
520: </head>
521: <body bgcolor="#FFFFFF">
522: <img align=right src=/adm/lonIcons/lonlogos.gif>
523: <h1>Create User, Change User Privileges</h1>
524: ENDTHREEHEAD
1.6 www 525: $r->print('<h2>'.$ENV{'form.cuname'}.' at '.$ENV{'form.cdomain'}.'</h2>');
1.4 www 526: if ($ENV{'form.makeuser'}) {
527: $r->print('<h3>Creating User</h3>');
528: if (($ENV{'form.cuname'})&&($ENV{'form.cuname'}!~/\W/)&&
529: ($ENV{'form.cdomain'})&&($ENV{'form.cdomain'}!~/\W/)) {
530: my $amode='';
531: my $genpwd='';
532: if ($ENV{'form.login'} eq 'krb') {
533: $amode='krb4';
534: $genpwd=$ENV{'form.krbdom'};
535: } elsif ($ENV{'form.login'} eq 'int') {
536: $amode='internal';
537: $genpwd=$ENV{'form.intpwd'};
1.20 ! harris41 538: } elsif ($ENV{'form.login'} eq 'fsys') {
! 539: $amode='unix';
! 540: $genpwd=$ENV{'form.fsyspwd'};
1.18 albertel 541: } elsif ($ENV{'form.login'} eq 'loc') {
542: $amode='localauth';
543: $genpwd=$ENV{'form.locarg'};
544: if (!$genpwd) { $genpwd=" "; }
545: }
1.4 www 546: if (($amode) && ($genpwd)) {
1.6 www 547: $r->print('Generating user: '.&Apache::lonnet::modifyuser(
1.4 www 548: $ENV{'form.cdomain'},$ENV{'form.cuname'},
549: $ENV{'form.cstid'},$amode,$genpwd,
550: $ENV{'form.cfirst'},$ENV{'form.cmiddle'},
1.6 www 551: $ENV{'form.clast'},$ENV{'form.cgen'}));
552: $r->print('<br>Home server: '.&Apache::lonnet::homeserver
1.20 ! harris41 553: ($ENV{'form.cuname'},$ENV{'form.cdomain'}));
! 554:
! 555: } else {
! 556: $r->print('Invalid login mode or password');
! 557: }
! 558: } else {
! 559: $r->print('Invalid username or domain');
! 560: }
! 561: }
! 562: if (!$ENV{'form.makeuser'} and $ENV{'form.login'} ne 'nop') {
! 563: $r->print('<h3>Changing User Login Data</h3>');
! 564: if (($ENV{'form.cuname'})&&($ENV{'form.cuname'}!~/\W/)&&
! 565: ($ENV{'form.cdomain'})&&($ENV{'form.cdomain'}!~/\W/)) {
! 566: my $amode='';
! 567: my $genpwd='';
! 568: if ($ENV{'form.login'} eq 'krb') {
! 569: $amode='krb4';
! 570: $genpwd=$ENV{'form.krbdom'};
! 571: } elsif ($ENV{'form.login'} eq 'int') {
! 572: $amode='internal';
! 573: $genpwd=$ENV{'form.intpwd'};
! 574: } elsif ($ENV{'form.login'} eq 'fsys') {
! 575: $amode='unix';
! 576: $genpwd=$ENV{'form.fsyspwd'};
! 577: } elsif ($ENV{'form.login'} eq 'loc') {
! 578: $amode='localauth';
! 579: $genpwd=$ENV{'form.locarg'};
! 580: if (!$genpwd) { $genpwd=" "; }
! 581: }
! 582: if (($amode) && ($genpwd)) {
! 583: $r->print('Modifying authentication: '.
! 584: &Apache::lonnet::modifyuserauth(
! 585: $ENV{'form.cdomain'},$ENV{'form.cuname'},
! 586: $amode,$genpwd);
! 587: $r->print('<br>Home server: '.&Apache::lonnet::homeserver
1.6 www 588: ($ENV{'form.cuname'},$ENV{'form.cdomain'}));
589:
1.4 www 590: } else {
591: $r->print('Invalid login mode or password');
592: }
593: } else {
594: $r->print('Invalid username or domain');
595: }
596: }
597: my $now=time;
1.6 www 598: $r->print('<h3>Modifying Roles</h3>');
1.4 www 599: map {
600: if (($_=~/^form\.rev\:([^\_]+)\_([^\_]+)$/) && ($ENV{$_})) {
601: $r->print('Revoking '.$2.' in '.$1.': '.
602: &Apache::lonnet::assignrole($ENV{'form.cdomain'},$ENV{'form.cuname'},
603: $1,$2,$now).'<br>');
1.11 www 604: if ($2 eq 'st') {
605: $1=~/^\/(\w+)\/(\w+)/;
606: my $cid=$1.'_'.$2;
607: $r->print('Drop from classlist: '.
608: &Apache::lonnet::critical('put:'.$ENV{'course.'.$cid.'.domain'}.':'.
609: $ENV{'course.'.$cid.'.num'}.':classlist:'.
610: &Apache::lonnet::escape($ENV{'form.cuname'}.':'.
611: $ENV{'form.cdomain'}).'='.
612: &Apache::lonnet::escape($now.':'),
613: $ENV{'course.'.$cid.'.home'}).'<br>');
614: }
1.4 www 615: }
616: } keys %ENV;
617: map {
618: if (($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_([^\_]+)$/) && ($ENV{$_})) {
1.5 www 619: my $url='/'.$1.'/'.$2;
620: if ($ENV{'form.sec_'.$1.'_'.$2.'_'.$3}) {
621: $url.='/'.$ENV{'form.sec_'.$1.'_'.$2.'_'.$3};
622: }
623: my $start=$now;
624: if ($ENV{'form.start_'.$1.'_'.$2.'_'.$3}) {
625: $start=$ENV{'form.start_'.$1.'_'.$2.'_'.$3};
626: }
627: my $end=0;
628: if ($ENV{'form.end_'.$1.'_'.$2.'_'.$3}) {
629: $end=$ENV{'form.end_'.$1.'_'.$2.'_'.$3};
630: }
631: $r->print('Assigning: '.$3.' in '.$url.': '.
632: &Apache::lonnet::assignrole($ENV{'form.cdomain'},$ENV{'form.cuname'},
633: $url,$3,$end,$start).'<br>');
1.10 www 634: if ($3 eq 'st') {
1.11 www 635: $url=~/^\/(\w+)\/(\w+)/;
636: my $cid=$1.'_'.$2;
1.10 www 637: $r->print('Add to classlist: '.
638: &Apache::lonnet::critical('put:'.$ENV{'course.'.$cid.'.domain'}.':'.
639: $ENV{'course.'.$cid.'.num'}.':classlist:'.
640: &Apache::lonnet::escape($ENV{'form.cuname'}.':'.
641: $ENV{'form.cdomain'}).'='.
642: &Apache::lonnet::escape($end.':'.$start),
643: $ENV{'course.'.$cid.'.home'}).'<br>');
644: }
1.8 www 645: } elsif (($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) && ($ENV{$_})) {
646: my $url='/'.$1.'/';
647: my $start=$now;
648: if ($ENV{'form.start_'.$1.'_'.$2}) {
649: $start=$ENV{'form.start_'.$1.'_'.$2};
650: }
651: my $end=0;
652: if ($ENV{'form.end_'.$1.'_'.$2}) {
653: $end=$ENV{'form.end_'.$1.'_'.$2};
654: }
655: $r->print('Assigning: '.$2.' in '.$url.': '.
656: &Apache::lonnet::assignrole($ENV{'form.cdomain'},$ENV{'form.cuname'},
657: $url,$2,$end,$start).'<br>');
658: }
1.4 www 659: } keys %ENV;
1.5 www 660: $r->print('</body></html>');
1.4 www 661: }
662:
1.2 www 663: # ================================================================ Main Handler
664: sub handler {
665: my $r = shift;
666:
667: if ($r->header_only) {
668: $r->content_type('text/html');
669: $r->send_http_header;
670: return OK;
671: }
672:
673: if ((&Apache::lonnet::allowed('cta',$ENV{'request.course.id'})) ||
674: (&Apache::lonnet::allowed('cin',$ENV{'request.course.id'})) ||
675: (&Apache::lonnet::allowed('ccr',$ENV{'request.course.id'})) ||
676: (&Apache::lonnet::allowed('cep',$ENV{'request.course.id'})) ||
1.19 www 677: (&Apache::lonnet::allowed('cca',$ENV{'user.domain'})) ||
1.2 www 678: (&Apache::lonnet::allowed('mau',$ENV{'user.domain'}))) {
679: $r->content_type('text/html');
680: $r->send_http_header;
681: unless ($ENV{'form.phase'}) {
682: &phase_one($r);
683: }
684: if ($ENV{'form.phase'} eq 'two') {
685: &phase_two($r);
1.4 www 686: } elsif ($ENV{'form.phase'} eq 'three') {
687: &phase_three($r);
1.2 www 688: }
1.1 www 689: } else {
690: $ENV{'user.error.msg'}=
1.9 albertel 691: "/adm/createuser:mau:0:0:Cannot modify user data";
1.1 www 692: return HTTP_NOT_ACCEPTABLE;
693: }
694: return OK;
695: }
696:
697: 1;
698: __END__
1.2 www 699:
700:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>