Hi there,

            When I had to install ASSP I made these lousy scripts to obtain 
the info from the registry.
            Perhaps they can help somebody else.
            They have some debug over there, but it works.
            Sometime soon, I will update these scripts so they can be run 
automatically by a cron and update the assp needed files.
            Regards!
Javier Albinarrate

--------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------
File: imail.dump.domains.pl
use Win32::Registry;

my $ImailDomainBase = 'SOFTWARE\Ipswitch\IMail\Domains';

my %RegType = (
   0 => 'REG_0',
   1 => 'REG_SZ',
   2 => 'REG_EXPAND_SZ',
   3 => 'REG_BINARY',
   4 => 'REG_DWORD',
   5 => 'REG_DWORD_BIG_ENDIAN',
   6 => 'REG_LINK',
   7 => 'REG_MULTI_SZ',
   8 => 'REG_RESOURCE_LIST',
   9 => 'REG_FULL_RESOURCE_DESCRIPTION',
   10 => 'REG_RESSOURCE_REQUIREMENT_MAP');


my (%aLocalDomains, $hkey, @aDomainList, $key, 
$hDomain,$kDomainList,%hDomainValues,$kDomainValues, $RegKey, $RegType, 
$RegValue);

$HKEY_LOCAL_MACHINE->Open($ImailDomainBase,$kDomainList)|| die $!;
$kDomainList->GetKeys([EMAIL PROTECTED]);

foreach $key (@aDomainList){
  print 
"-----------------------------------------------------------------------------\n";
  $HKEY_LOCAL_MACHINE->Open($ImailDomainBase.'\\'.$key, $kDomainValues)|| 
die $!;
  $kDomainValues->GetValues(\%hDomainValues);
  foreach $value (keys(%hDomainValues)){
   $RegKey  = $hDomainValues{$value}->[0];
   $RegType  = $hDomainValues{$value}->[1];
   $RegValue = $hDomainValues{$value}->[2];
    if ($RegKey eq 'Official'){
      print "Official: $RegValue\n";
      if (!exists($aLocalDomains{$RegValue})){
        $aLocalDomains{$RegValue} = true;
        print "-- Added\n";
      }
    }
    if ($RegKey eq 'Aliases'){
      print "Aliases: $RegValue\n";
      @aAlises = split(/[\s+\0]+/, $RegValue);
      foreach $sAlias (@aAlises){
        if ($sAlias =~ /^[\w-\.]+$/){
          print "\t$sAlias\n";
          push(@aLocalDomains,$sAlias);
          if (!exists($aLocalDomains{$sAlias})){
            $aLocalDomains{$sAlias} = true;
            print "-- Added\n";
          }
        }
      }
    }
 }
  $kDomainValues->Close();
}
$kDomainList->Close();

print 
"========================================================================================================\n";

foreach $domain (keys %aLocalDomains){
  print "$domain\n";
}





--------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------
File: imail.dump.users.pl

use Win32::Registry;

my $debug = 0;

my $ImailDomainBase = 'SOFTWARE\Ipswitch\IMail\Domains';

my %RegType = (
   0 => 'REG_0',
   1 => 'REG_SZ',
   2 => 'REG_EXPAND_SZ',
   3 => 'REG_BINARY',
   4 => 'REG_DWORD',
   5 => 'REG_DWORD_BIG_ENDIAN',
   6 => 'REG_LINK',
   7 => 'REG_MULTI_SZ',
   8 => 'REG_RESOURCE_LIST',
   9 => 'REG_FULL_RESOURCE_DESCRIPTION',
   10 => 'REG_RESSOURCE_REQUIREMENT_MAP');


my (@aLocalUsers, @aDomainList, $domain, $value, $user, 
$kDomainList,$kDomainUsers);

$HKEY_LOCAL_MACHINE->Open($ImailDomainBase,$kDomainList)|| die $!;
$kDomainList->GetKeys([EMAIL PROTECTED]);

foreach $domain (@aDomainList){
  if ($debug){
     print 
"-----------------------------------------------------------------------------\n";
  }
  if ($HKEY_LOCAL_MACHINE->Open($ImailDomainBase.'\\'.$domain.'\Users', 
$kDomainUsers)){
   @aUsersList = ();
   $kDomainUsers->GetKeys([EMAIL PROTECTED]);
   foreach $value (@aUsersList){
     if ($value ne '_aliases' && $value ne 'root'){
       $user = $value.'@'.$domain;
       if ($debug){
        print "$user\n";
       }
       push(@aLocalUsers,$user);
     }
  }
   $kDomainUsers->Close();
  }
  break;
}
$kDomainList->Close();

if ($debug){
  print 
"========================================================================================================\n";
}

foreach $user (@aLocalUsers){
  print "$user\n";
}

--------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------

----- Original Message ----- 
From: "Matti Haack" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, August 16, 2006 10:54 AM
Subject: [Assp-user] ASSP with Imail - Scripts to export Users and 
Domainsand all Aliasses


> Hello,
>
> for  anybody,  who uses Imail and likes to test ASSP, I just created some 
> scripts to
> export  Users  and  Domains for ASSP. It is designed to work only with
> Imails virtual Domains.
>
> Works great for us with 230+ Domains and aprox 1000 Users.
>
> They  are  quick  and  dirty and "compiled" from the scripts mentioned
> here some times ago.
> I run the batch in a scedule to sync imail with assp.
>
> a) imail-adresses.vbs
> Prints  out   all   valid   email   Adresse  for  all  Domains, Users,
> Domain- and User-Aliases
> ------------------------------------------------------------
>
> const HKEY_LOCAL_MACHINE = &H80000002
> strComputer = "."
> Set StdOut = WScript.StdOut
>
> Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" 
> &strComputer & "\root\default:StdRegProv")
>
> strKeyPath = "Software\Ipswitch\IMail\Domains"
>
> ' List the Domain keys
> oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
>
> For Each subkey In arrSubKeys
>  If left(subkey,8) <> "$virtual" Then
>
>
>    ' Find the domains keys with a Users key
>    oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey, arrSubKeys2
>
>    If not isnull(arrSubKeys2) Then
>      For Each subkey2 In arrSubKeys2
>
>        If subkey2 = "Users" Then
>
>
>
>          ' List the aliases
>          oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey 
> &"\Users\_aliases", arrValueNames, arrValueTypes
>
>          If not isnull(arrValueNames) Then
>            nobody=0
>            For i = 0 to UBound(arrValueNames)
>               if arrValueNames(i)="nobody" then nobody=1
>            next
>
>            For i = 0 to UBound(arrValueNames)
>
>                oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" 
> &subkey & "\Users\_aliases", arrValueNames(i), strValue
>                oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" 
> &subkey , "Address", address
>
>                strValueName = "Aliases"
>                oReg.GetMultiStringValue HKEY_LOCAL_MACHINE, strKeyPath & 
> "\" &address , strValueName, arrValues
>
>
>                if arrValueNames(i)<>"nobody" then
>                        if nobody=0 then StdOut.writeline arrValueNames(i)& 
> "@" & subkey
>                else
>                        StdOut.WriteLine "@" & subkey
>                end if
>
>                If not isnull(arrValues) Then
>                For each alias in arrValues
>                if arrValueNames(i)<>"nobody" then
>                        if nobody=0 then StdOut.writeline 
> arrValueNames(i)&"@"&alias
>                else
>                        StdOut.WriteLine "@" & alias
>                end if
>
>
>                Next
>                End If
>
>            Next
>          End If
>                ' List the users
>          oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey 
> &"\Users", arrSubKeys3
>
>          If not isnull(arrsubkeys3) Then
>            For each subkey3 in arrSubKeys3
>              If subkey3 <> "_aliases" Then
>
>                if nobody=0 then StdOut.WriteLine subkey3 & "@" & subkey
>                If not isnull(arrValues) Then
>
>                        For each alias in arrValues
>                        if nobody=0 then StdOut.writeline subkey3 
> &"@"&alias
>                        next
>                End If
>               End if
>            Next
>          End If
>
>        End If
>
>      Next
>    End If
>
>  End If
> Next
> StdOut.writeline "root"
> StdOut.writeline "postmaster"
> ------------------------------
>
>
>
>
>
> b) imail-domains.vbs
> Prints all Local Domains/Domainaliases:
> ------------------------------
>
> const HKEY_LOCAL_MACHINE = &H80000002
> strComputer = "."
> Set StdOut = WScript.StdOut
>
> Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" 
> &strComputer & "\root\default:StdRegProv")
>
> strKeyPath = "Software\Ipswitch\IMail\Domains"
>
> ' List the Domain keys
> oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
>
> For Each subkey In arrSubKeys
>  If left(subkey,8) = "$virtual" Then
>
>    strValueName = "Official"
>    oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" &subkey , 
> strValueName, strValue
>
>        StdOut.WriteLine strValue
>
>    strValueName = "Aliases"
>    oReg.GetMultiStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" &subkey , 
> strValueName, arrValues
>    For Each strValue In arrValues
>        StdOut.WriteLine  strValue
>    Next
>   end if
>
> Next
>
> ' Put the Domainaliases and domain of your Local Host here:
> StdOut.WriteLine "mail.internethit.de"
> StdOut.WriteLine "haack-it.de"
> StdOut.WriteLine "haack-it.at"
>
> -------------------------------------
>
>
>
> c) domains.bat
> a batchfile wich combines everything:
> -------------------------------------
>
> cscript imail-adresses.vbs //NoLogo > h:\assp\users.txt
> cscript imail-domains.vbs //NoLogo > h:\assp\domains.txt
>
> -------------------------------------
>
>
> Greetings
>         Matti
>
>
>
> -
> Matti Haack - Hit Haack IT Service Gmbh
> Poltlbauer Weg 4, D-94036 Passau
> +49 851 50477-22 Fax: +49 851 50477-29
> http://www.haack-it.de
>
>
>
> Dieses Dokument ist ausschliesslich fuer den Adressaten bestimmt.
> Jegliche Art von Reproduktion, Verbreitung, Vervielfaeltigung, 
> Modifikation,
> Verteilung und/oder Publikation dieser E-Mail-Nachricht ist untersagt,
> soweit dies nicht  ausdruecklich genehmigt wurde. Jegliche Haftung fur
> Ansprueche,  die aufgrund der Kommunikation per E-Mail begruendet
> werden koennten, ist ausgeschlossen, soweit der Haftungsausschluss
> gesetzlich zulaessig ist.
>
> -- Ausgehende E-Mail wurde auf Viren gescannt  --
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job 
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Assp-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/assp-user
>
> 


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Assp-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/assp-user

Reply via email to