Page 1 of 1

Script to create user account?

Posted: 2005-07-21 02:57
by chaikw
Hi there,

I newby.

I using Windows 2003 server, IIS6, PHP 5.0.3, hMailServer 4.0-B125 and SM for hMailServer Mod 0.1.

It's there any scripts to auto-create user accounts? So that I not need to create account one-by-one.

Thanks.

Posted: 2005-07-21 08:50
by martin
That depends on how you want to create them. I assume you don't want a script that just creates random accounts? :)

Posted: 2005-07-21 10:43
by chaikw
Hi Martin,

Thanks for quick reply.

Something like the script read from database (MSSQL or MYSQL) contain the username, user personal information, default password, etc and create the account.

Cause this project mainly for students to use - about 200 users. I can't create one-by-one. :shock:

Any sample or referenece? :wink:

Thanks.

Posted: 2005-07-21 18:35
by martin
There currently are such a tool. Do you have the student list in a database or in a text file or so? If you have them in a text file, you can use TextFileMigrate.exe to import the users. But that only imports username/password/accountsize and needs to be formatted properly. Let me know if you want instructions for this..

Posted: 2005-07-21 18:49
by mrcolj
I just used textmigrate--worked as flawlessly as I expected.

If it's simple, I'd like a version that creates aliases... maybe so i could say:
user,password,quota,alias

because mine is one of those companies where everyone's real email address is some id number, i.e. 13241235@dmrevolution.com, and then everyone gets one or more aliases to represent their public address, i.e. jsmith@dmrevolution.com or john.smith@dmrevolution.com.

Posted: 2005-07-22 01:25
by chaikw
Hi Martin & mrcolj,

Thanks for your information.

Yes, can I know where to download the TextFileMigrate.exe and how to use it (sample of the format)?

Thanks a lot :D

Posted: 2005-07-22 19:51
by mrcolj
This folder has said files... Click here.

I'm thinking my earlier request, to have an option for creating aliases in like manner would be easier handled by a separate alias application, that would just use a file like:

alias,user

While we're at it, is there a reason the ability to import CSVs is not just made an integral part of the administration program?

Anyway, martin probably wants someone else to take the lead with something like that. I'd do all I can, but I don't have any VB skills... Who's got those skills and is willing to volunteer to be a contributing member of society?

Posted: 2005-07-23 03:16
by chaikw
Hi Colin Jensen,

Thanks a lot :D .

Only thing is how to use it :oops: Any help file or example?

Thanks.

Posted: 2005-07-23 09:11
by martin
Download textfilemigrate4.zip and read the sample.txt

Textfilemigrate.exe allows you to select which file to import.

Posted: 2005-07-24 08:05
by chaikw
Hi Martin,

Thanks. I will try it out. :D

Posted: 2005-07-24 16:31
by boonchuan
Anyway to enable it for mailenable migration?

Add Users Script

Posted: 2005-09-21 17:14
by JasonMcFeetors
Here is the code I created for adding a user to hMailServer. It is written in vbscript:

Code: Select all

Option Explicit

Dim obBaseApp
Dim objFSO
Dim objTextFile
Dim strNewUser,i

Const ForReading = 1
 
Set obBaseApp = CreateObject("hMailServer.Application") 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("Users.csv", ForReading)

Do While objTextFile.AtEndOfStream <> True
    strNewUser = split(objTextFile.Readline, ",")
    AddUser strNewUser(0), strNewUser(1), strNewUser(2)
    i = i + 1
Loop

Sub AddUser(strUsername, strPassword, strDomain)
	Dim obDomain 
	Dim obAccounts 
	Dim obNewAccount

	Set obDomain = obBaseApp.Domains.ItemByName(strDomain) 
	Set obAccounts = obDomain.Accounts
	Set obNewAccount = obAccounts.Add() 
	
	obNewAccount.Address = strUsername & "@" & strDomain 'username
	obNewAccount.Password = strPassword 'password
	obNewAccount.Active = 1 'activates user
	obNewAccount.Maxsize = 0 'sets mailbox size, 0=unlimited
	obNewAccount.Save() 'saves account
	
	Set obNewAccount = Nothing
	Set obDomain = Nothing	
	Set obAccounts = Nothing
	
End Sub
This also requires a CSV file called Users.csv in the same directory as the script. The CSV is in the following format:

Code: Select all

username,password,domain
Simply add all of your users to the CSV, run the script and away it goes!

Jason

Posted: 2005-09-30 21:34
by mrcolj
thanks Jason,

in line with my above question, is there any way to add in a fourth "alias" column that would automatically create aliases for those users? Or even a second program?

Thanks.

Posted: 2005-09-30 22:13
by mrcolj
Martin, on textfilemigrate:

If I want to add 10 new people, do I need to run the program again with a CSV of all 1000 usernames,passwords,quotas , or just the 10 new ones? Meaning if I run it right now with 10, will it delete everyone else, or just add 10?

Thanks Martin.

Posted: 2005-09-30 22:16
by martin
The program should only do add's, not deletes. So it should be enough to give it the next 10. But I suggest you take a backup before doing it..

Posted: 2006-03-08 21:17
by vlskip
is there a reason why this would not work on windows 2000 server ?

nothing happens when i start it. :confused:

Posted: 2006-03-08 21:22
by martin
What did you do? Did you run the program or the script?

Posted: 2006-03-08 21:41
by vlskip
created the csv, placed in the same folder and double clicked on the script.

should i run it in another way ?

Posted: 2006-03-08 21:50
by CraigHarris
To run the script, run:

Code: Select all

WScript ScriptName.vbs

Posted: 2006-03-08 22:13
by vlskip
weird... still nothing hapening.

c:\script.vbs
c:\objects.csv

cmd
cd \
wscript script.vbs


nothing happens... just returning to my prompt with no eror

Posted: 2006-03-08 22:31
by CraigHarris
This also requires a CSV file called Users.csv in the same directory as the script
... you don't seem to have that file.

Re: Script to create user account?

Posted: 2008-03-26 23:29
by gingercat
These scripts are a few years old now. Is there a newer or better way to import users now?

The script gives me errors about authentication - is there a later version now?

Re:

Posted: 2008-03-26 23:36
by gingercat
martin wrote:Download textfilemigrate4.zip and read the sample.txt

Textfilemigrate.exe allows you to select which file to import.
Yeah but where from. The link about wont let me browse the directory

Re: Script to create user account?

Posted: 2008-04-01 20:59
by oneclicksolution
i'm also looking for an item like this...please let me know as well.

Re: Script to create user account?

Posted: 2008-10-16 20:37
by jjarzabek
I know this is an old topic but does anyone have the files? I'm looking to add around 2K+ accounts to a new hMailServer and could really use the migration program.

Re: Script to create user account?

Posted: 2008-10-16 20:50
by martin
Did you read the topic? There's a script just a few posts before yours with a script to import from text file.

Apart from that, the migration tool is located here:
http://download.hmailserver.com/utiliti ... igrate.zip

Re: Script to create user account?

Posted: 2008-10-16 21:00
by jjarzabek
Yes, I did read the topic. I see the script. But the link for the migration tool was not working. I was looking for the tool.

Thanks for updating the link.

Re: Script to create user account?

Posted: 2008-10-17 17:21
by jjarzabek
I know the text file has to be in the same folder as the exe. What is the best folder to run the whole operation in?

Re: Script to create user account?

Posted: 2008-10-21 15:39
by jjarzabek
Martin or anyone else? -> Best way to run this? <-

Re: Script to create user account?

Posted: 2008-10-21 15:40
by ^DooM^
Hows about make a backup of your hMail Dir then just try it :)

Re: Script to create user account?

Posted: 2008-10-21 16:00
by jjarzabek
Very funny, but with a large list (2000+), I'd like the best practice first! :mrgreen:

Re: Script to create user account?

Posted: 2008-10-21 19:02
by martin
It's a 3-step (or something close to that) wizard where you specify the text file location and domain to import into the accounts into. It's kind of hard to add any best practice information to that except for what ^DooM^ has already said... :) You may want to inform your users that you're doing maintenance on the server. Shouldn't affect them but anyway.

Re: Script to create user account?

Posted: 2009-12-30 00:10
by pranjut
hey guys
can anyone please tell me how can create the accounts using java???
please reply..

Re: Script to create user account?

Posted: 2009-12-30 01:34
by mattg
There is a VBS script about 10 posts up.

You could use it, or even use it as a starting point.
You may want to check the latest COM API documentation as the COM API has changed significantly from ver 4 to ver 5...

http://www.hmailserver.com/documentatio ... om_objects

Re: Script to create user account?

Posted: 2009-12-30 22:39
by pranjut
Thanx mattg, but I don't understand VBScript so I can't convert it to java... so please please give me a way to do it through java....

Re: Script to create user account?

Posted: 2009-12-30 22:40
by martin
pranjut,
Is it even possible to access Microsoft COM with Java?

Re: Script to create user account?

Posted: 2009-12-30 22:55
by pranjut
I've no idea.......

Re: Script to create user account?

Posted: 2009-12-30 22:58
by pranjut
is it possible that, account can be created using telnet in hmail?? if yes how, if no that's also ok...

Re: Script to create user account?

Posted: 2009-12-30 23:04
by martin
hMailServers API is based on COM. If you cannot access COM from Java, you cannot access the hMailServer API. I would suggest that you read the documentation for the language you've chosen.

And no, it's not possible to telnet to hMailServer to create accounts.

Re: Script to create user account?

Posted: 2009-12-30 23:19
by pranjut
thanks martin...... :)

Re: Script to create user account?

Posted: 2014-09-03 09:04
by catamarancn
update the script

Code: Select all

Option Explicit

Dim obBaseApp
Dim objFSO
Dim objTextFile
Dim strNewUser,i

Const ForReading = 1

Set obBaseApp = CreateObject("hMailServer.Application") 
Call obBaseApp.Authenticate("Administrator","admin password")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("user.csv", ForReading)

Do While objTextFile.AtEndOfStream <> True
    strNewUser = split(objTextFile.Readline, ",")
    AddUser strNewUser(0), strNewUser(1), strNewUser(2)
    i = i + 1
Loop

Sub AddUser(strUsername, strPassword, strDomain)
   Dim obDomain 
   Dim obNewAccount
	'WScript.Echo obBaseApp.Domains
   Set obDomain = obBaseApp.Domains.ItemByName(strDomain) 
   Set obNewAccount = obDomain.Accounts.Add() 
   
   obNewAccount.Address = strUsername & "@" & strDomain 'username   
	obNewAccount.Password = strPassword 'password
	obNewAccount.Active = 1 'activates user
	obNewAccount.Maxsize = 1024 'sets mailbox size, 0=unlimited
	obNewAccount.Save() 'saves account

   Set obNewAccount = Nothing
   Set obDomain = Nothing   
   
End Sub

Re: Script to create user account?

Posted: 2014-09-03 13:14
by percepts