ispman/bin ispman.addUser,1.8,1.9

Joerg Delker <[email protected]>
Newsgroups gmane.comp.isp.ispman.cvs
Message-ID <[email protected]>
Update of /cvsroot/ispman/ispman/bin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2998/bin

Modified Files:
	ispman.addUser 
Log Message:
adjusted to new getDefault...Host functions

Index: ispman.addUser
===================================================================
RCS file: /cvsroot/ispman/ispman/bin/ispman.addUser,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ispman.addUser	4 Oct 2003 03:17:11 -0000	1.8
+++ ispman.addUser	17 Apr 2004 16:51:10 -0000	1.9
@@ -39,12 +39,12 @@
 
 my $r=new CGI();
 
+# provide defaults when unset
 $opts{'f'}||=$user;
 $opts{'l'}||=$user;
 $opts{'p'}||="secret";
 
-
-
+# fill parameters for addUser
 $r->param("givenName", $opts{"f"});
 $r->param("sn", $opts{"l"});
 $r->param("ispmanDomain", $opts{"d"});
@@ -52,52 +52,54 @@
 $r->param("userPassword", $opts{"p"});
 $r->param("mailQuota", $opts{"q"}) if $opts{"q"};
 
+# check domain
+my $domain=$ispman->getDomainInfo($opts{'d'});
 
+unless ($domain){
+    print "unkown domain \"$opts{'d'}\"!\n";
+    exit 1;
+}
 
 # If we dont want to create a mailbox for this user we
 # can specify -m none  perhaps for just mailforwardings
 unless ($opts{"m"} eq "none") {
-       if ($opts{"m"}){
-          # there should be some checking here that value of -m is actually
-          # a host defined in LDAP
-            $r->param("mailHost", $opts{"m"});
-         } elsif ($_mailhost=$ispman->getDomainAttribute($opts{'d'}, "ispmanDomainDefaultMailDropHost")){
-           # see if there is a ispmanDomainDefaultMailDropHost defined
-           # for this domain
-           $r->param("mailHost", $_mailhost);
-         } elsif ($_mailhost=$ispman->getHostGroupFirstMember('mailstoregroup')){
-           # try to get the first member from the mailstore group
-           $r->param("mailHost", $_mailhost);
-         } else {
-           # all failed. die with warning
-           print "Automatic detection for mailhost failed\n";
-           print "Please either define a mailhost for this user or define\n-m none\n";
-           exit;
-         }
+    if ($opts{"m"}){
+	# there should be some checking here that value of -m is actually
+	# a host defined in LDAP
+	$r->param("mailHost", $opts{"m"});
+
+    } elsif ($_mailhost=$ispman->getDefaultMailHost($opts{'d'})){
+	# see if there is a ispmanDomainDefaultMailDropHost defined
+	# for this domain
+	$r->param("mailHost", $_mailhost);
+
+    } else {
+	# all failed. die with warning
+	print "Automatic detection for mailhost failed\n";
+	print "Please either define a mailhost for this user or define\n-m none\n";
+	exit;
+    }
 }
 
 # We need to know on which host to create the homeDirectory for this user.
 # We can have one or more fileservers.
 
 unless ($opts{"h"} eq "none") {
-       if ($opts{"h"}){
-          # there should be some checking here that value of -h is actually
-          # a host defined in LDAP
-            $r->param("fileHost", $opts{"h"});
-         } elsif ($_filehost=$ispman->getDomainAttribute($opts{'d'}, "ispmanDomainDefaultFileServer")){
-           # see if there is a ispmanDomainDefaultFileServer defined
-           # for this domain
-           $r->param("fileHost", $_filehost);
-         } elsif ($_filehost=$ispman->getHostGroupFirstMember('fileservergroup')){
-           # try to get the first member from the fileservergroup
-           $r->param("fileHost", $_filehost);
-         } else {
-           # all failed. die with warning
-           print "Please define a filehost for this user where the homedirectory should be created with the -h switch \n";
-           exit;
-         }
-}
+    if ($opts{"h"}){
+	# there should be some checking here that value of -h is actually
+	# a host defined in LDAP
+	$r->param("fileHost", $opts{"h"});
+
+    } elsif ($_filehost=$ispman->getDefaultFileHost($opts{"d"})){
+	# get fileHost suggestio
+	$r->param("fileHost", $_filehost);
 
+    } else {
+	# all failed. die with warning
+	print "Please define a filehost for this user where the homedirectory should be created with the -h switch \n";
+	exit;
+    }
+}
 
 
 $ispman->addUser($r);



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.