ispman/lib/ISPMan UserMan.pm,1.60,1.61

Joerg Delker <[email protected]> Wed, 15 Nov 2006 22:23:32 +0000
Newsgroups gmane.comp.isp.ispman.cvs
Message-ID <[email protected]>
Update of /cvsroot/ispman/ispman/lib/ISPMan
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv5367/lib/ISPMan

Modified Files:
	UserMan.pm 
Log Message:
fixing mail alias check

Index: UserMan.pm
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/ISPMan/UserMan.pm,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- UserMan.pm	25 Oct 2006 20:49:20 -0000	1.60
+++ UserMan.pm	15 Nov 2006 22:23:29 -0000	1.61
@@ -138,8 +138,12 @@
     $r->param( "uid", $_uid );
 
     # check uid conflicts with existing mail addresses
-    if ( my $check = $self->getDNForMailAddress(
-       join '@', ($r->param("userid"), $r->param("ispmanDomain"))) ) {
+    if (
+        my $check = $self->getDNForMailAddress(
+            join '@', ( $r->param("userid"), $r->param("ispmanDomain") )
+        )
+      )
+    {
         print "Unable to create user \"$_uid\", because mail address is<br>"
           . "already blocked by \"$check\".";
         return;
@@ -205,7 +209,7 @@
 sub getDNForMailAddress {
     my $self  = shift;
     my $found = "";
-    while ( ! $found && (my $mail = shift )) {
+    while ( !$found && ( my $mail = shift ) ) {
         my $entries =
           $self->getEntriesAsHashRef( $self->{'Config'}->{'ldapBaseDN'},
             "|(mailLocalAddress=$mail)(mailAlias=$mail)" );
@@ -361,12 +365,13 @@
       $self->as_arrayref( split( /\s+/, $r->param("mailAlias") ) );
 
     # check uniqueness of mail aliases
-    if ( my $check =
-        $self->getDNForMailAddress( split( /\s+/, $r->param("mailAlias") ) ) )
-    {
-        print "Mail aliases conflict with \"$check\".<br>";
-        print "Aborting update!";
-        return 0;
+    for ( split( /\s+/, $r->param("mailAlias") ) ) {
+        my $found_dn = $self->getDNForMailAddress($_);
+        if ( defined($found_dn) && ( $found_dn ne $dn ) ) {
+            print "Mail alias $_ conflicts with \"$found_dn\".<br>";
+            print "Aborting update!";
+            return 0;
+        }
     }
 
     # added by Michael Bunk, Jan 2006
@@ -496,7 +501,7 @@
 sub getUserCount {
     my $self   = shift;
     my $domain = shift;
-    my $base   = "ou=users, ispmanDomain=$domain, ";
+    my $base   = "ou=users,ispmanDomain=$domain, ";
     $base .= $self->getConf("ldapBaseDN");
 
     return $self->getCount( $base, "&(objectClass=ispmanDomainUser)", ["uid"] );
@@ -505,8 +510,8 @@
 sub getUsersBranchDN {
     my $self   = shift;
     my $domain = shift;
-    return join( ",",
-        "ou=users, ispmanDomain=$domain",
+    return
+      join( ",", "ou=users,ispmanDomain=$domain",
         $self->getConf('ldapBaseDN') );
 }
 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV