[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 04 Apr 2002 20:06:20 -0000


matthew		Thu Apr  4 15:06:20 2002 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Added $desiredhome parameter to allow setting the home server for a new
  user.
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.205 loncom/lonnet/perl/lonnet.pm:1.206
--- loncom/lonnet/perl/lonnet.pm:1.205	Wed Apr  3 12:44:50 2002
+++ loncom/lonnet/perl/lonnet.pm	Thu Apr  4 15:06:20 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.205 2002/04/03 17:44:50 www Exp $
+# $Id: lonnet.pm,v 1.206 2002/04/04 20:06:20 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1860,22 +1860,27 @@
 
 # --------------------------------------------------------------- Modify a user
 
-
 sub modifyuser {
-    my ($udom,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene,
-        $forceid)=@_;
+    my ($udom,    $uname, $uid,
+        $umode,   $upass, $first,
+        $middle,  $last,  $gene,
+        $forceid, $desiredhome)=@_;
     $udom=~s/\W//g;
     $uname=~s/\W//g;
     &logthis('Call to modify user '.$udom.', '.$uname.', '.$uid.', '.
              $umode.', '.$first.', '.$middle.', '.
-	     $last.', '.$gene.'(forceid: '.$forceid.') by '.
-             $ENV{'user.name'}.' at '.$ENV{'user.domain'});  
+	     $last.', '.$gene.'(forceid: '.$forceid.')'.
+             (defined($desiredhome) ? ' desiredhome = '.$desiredhome :
+                                     ' desiredhome not specified'). 
+             ' by '.$ENV{'user.name'}.' at '.$ENV{'user.domain'});
     my $uhome=&homeserver($uname,$udom);
 # ----------------------------------------------------------------- Create User
     if (($uhome eq 'no_host') && ($umode) && ($upass)) {
         my $unhome='';
 	if ($ENV{'course.'.$ENV{'request.course.id'}.'.domain'} eq $udom) {
 	    $unhome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'};
+        } elsif (defined($desiredhome) && $hostdom{$desiredhome} eq $udom) { 
+            $unhome = $desiredhome;
         } else {
             my $tryserver;
             my $loadm=10000000;
@@ -1890,7 +1895,8 @@
 	    }
         }
         if (($unhome eq '') || ($unhome eq 'no_host')) {
-	    return 'error: find home';
+	    return 'error: unable to find a home server for '.$uname.
+                   ' in domain '.$udom;
         }
         my $reply=&reply('encrypt:makeuser:'.$udom.':'.$uname.':'.$umode.':'.
                          &escape($upass),$unhome);