Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Extract Users and Domains for ASSP
PostPosted: 2007-08-02 13:38 
Normal user

Joined: 2004-04-30 12:54
Posts: 43
hello,

I made a script to create a list of valid users and domains to use with ASSP.

The script exports all Users and all local Domains to text files. Aliases, Lists and Catch-All will be handled.

Please edit the path and filenames (2 locations for each users and domain file) and your hmail-administrator password to your needs.

As ASSP has currently no event which is triggered on a configuration change, I suggest to run it with a cron job.

Matti

Code:
Set StdOut = WScript.StdOut
Dim obBaseApp
Set obBaseApp = CreateObject("hMailServer.Application")
Call obBaseApp.Authenticate("Administrator","YourPassword")


Dim fso, File, sText
Const ForWriting = 2

Set fso = CreateObject("Scripting.FileSystemObject")
set DomainFile = fso.OpenTextFile("c:\assp\domains.tmp", ForWriting, true)
set userFile = fso.OpenTextFile("c:\assp\users.tmp", ForWriting, true)







Dim obNewDomain
Set obNewDomain = obBaseApp.Domains.Add()



for x=0 to obBaseApp.Domains.Count-1
stdout.write "."
    Set obDomain = obBaseApp.Domains(x)
    domainfile.writeline obDomain.name
    'stdout.writeline obDomain.name
    user obDomain.name,x
    domainalias=obDomain.Domainaliases.count
    if domainalias>0 then
       for y=0 to domainalias-1
           set obDomainAlias=obDomain.Domainaliases(y)
           domainfile.writeline obDomainAlias.AliasName
           'stdout.writeline obDomainAlias.AliasName
           user obDomainAlias.Aliasname,x
       next
    end if
next


Set DomainFile = nothing
Set userFile = nothing


fso.CopyFile "c:\assp\users.tmp" , "c:\assp\users.txt", true
fso.CopyFile "c:\assp\domains.tmp" , "c:\assp\domains.txt", true




Set fso = nothing


sub user(domainname,itemnr)
Set fobDomain = obBaseApp.Domains(itemnr)
domain=fobDomain.name

  if len(fobDomain.postmaster)<2 then
 
 
  if fobDomain.accounts.count>0 then
     for a=0 to fobDomain.accounts.count-1
         if fobDomain.accounts(a).active=true then
            output=replace(fobDomain.accounts(a).Address,domain,domainname)
             userfile.writeline output
         end if
     next
  end if
 
  if fobDomain.aliases.count>0 then
     for a=0 to fobDomain.aliases.count-1
         if fobDomain.aliases(a).active=true then
           output=replace(fobDomain.aliases(a).name,domain,domainname)
           userfile.writeline output
         end if
     next
  end if
 
  if fobDomain.distributionlists.count>0 then
     for a=0 to fobDomain.distributionlists.count-1
         if fobDomain.distributionlists(a).active=true then
            output=replace(fobDomain.distributionlists(a).Address,domain,domainname)
            userfile.writeline output
         end if
     next
  end if
else
     userfile.writeline "@"&domainname
end if

end sub


Top
 Profile  
 
 Post subject:
PostPosted: 2007-12-12 21:25 
Normal user

Joined: 2006-10-19 18:57
Posts: 49
Great script, thank you very much.

It works perfectly for my instalation.

_________________
Regards

Dingo


Top
 Profile  
 
 Post subject:
PostPosted: 2007-12-13 19:45 
Normal user

Joined: 2006-12-22 07:58
Posts: 204
Location: Istanbul
works very good. thanks.
i had to rem out the line stdout.write "." btw. fyi.


Top
 Profile  
 
 Post subject:
PostPosted: 2007-12-14 11:08 
Normal user

Joined: 2004-04-30 12:54
Posts: 43
I think if you save it as .vbs and run it with cscript, it can use the "." in the output. Anyway, it was only to show me that it is working.


Top
 Profile  
 
 Post subject: Re: Extract Users and Domains for ASSP
PostPosted: 2013-04-19 15:20 
New user
New user

Joined: 2012-11-01 14:27
Posts: 6
Just implemented this - works perfectly

_________________
HostKing - South African Provider of web hosting, reseller hosting and email hosting. www.hostking.co.za


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 


Who is online

Users browsing this forum: No registered users and 2 guests



Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group