Script to create user account?

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
chaikw
Normal user
Normal user
Posts: 37
Joined: 2005-07-18 10:14
Location: Selangor, Malaysia

Script to create user account?

Post by chaikw » 2005-07-21 02:57

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.
Regards,
Chai Kam Weng

User avatar
martin
Developer
Developer
Posts: 6777
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2005-07-21 08:50

That depends on how you want to create them. I assume you don't want a script that just creates random accounts? :)

chaikw
Normal user
Normal user
Posts: 37
Joined: 2005-07-18 10:14
Location: Selangor, Malaysia

Post by chaikw » 2005-07-21 10:43

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.
Regards,
Chai Kam Weng

User avatar
martin
Developer
Developer
Posts: 6777
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2005-07-21 18:35

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..

mrcolj
Normal user
Normal user
Posts: 40
Joined: 2005-07-21 01:52
Location: North Little Rock, AR / Novato, CA
Contact:

Post by mrcolj » 2005-07-21 18:49

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.

chaikw
Normal user
Normal user
Posts: 37
Joined: 2005-07-18 10:14
Location: Selangor, Malaysia

Post by chaikw » 2005-07-22 01:25

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
Regards,
Chai Kam Weng

mrcolj
Normal user
Normal user
Posts: 40
Joined: 2005-07-21 01:52
Location: North Little Rock, AR / Novato, CA
Contact:

Post by mrcolj » 2005-07-22 19:51

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?

chaikw
Normal user
Normal user
Posts: 37
Joined: 2005-07-18 10:14
Location: Selangor, Malaysia

Post by chaikw » 2005-07-23 03:16

Hi Colin Jensen,

Thanks a lot :D .

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

Thanks.
Regards,
Chai Kam Weng

User avatar
martin
Developer
Developer
Posts: 6777
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2005-07-23 09:11

Download textfilemigrate4.zip and read the sample.txt

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

chaikw
Normal user
Normal user
Posts: 37
Joined: 2005-07-18 10:14
Location: Selangor, Malaysia

Post by chaikw » 2005-07-24 08:05

Hi Martin,

Thanks. I will try it out. :D
Regards,
Chai Kam Weng

boonchuan
New user
New user
Posts: 21
Joined: 2004-05-07 03:32

Post by boonchuan » 2005-07-24 16:31

Anyway to enable it for mailenable migration?

JasonMcFeetors
New user
New user
Posts: 4
Joined: 2005-06-23 20:46

Add Users Script

Post by JasonMcFeetors » 2005-09-21 17:14

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

mrcolj
Normal user
Normal user
Posts: 40
Joined: 2005-07-21 01:52
Location: North Little Rock, AR / Novato, CA
Contact:

Post by mrcolj » 2005-09-30 21:34

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.

mrcolj
Normal user
Normal user
Posts: 40
Joined: 2005-07-21 01:52
Location: North Little Rock, AR / Novato, CA
Contact:

Post by mrcolj » 2005-09-30 22:13

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.

User avatar
martin
Developer
Developer
Posts: 6777
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2005-09-30 22:16

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..

vlskip
New user
New user
Posts: 9
Joined: 2006-03-08 20:53

Post by vlskip » 2006-03-08 21:17

is there a reason why this would not work on windows 2000 server ?

nothing happens when i start it. :confused:

User avatar
martin
Developer
Developer
Posts: 6777
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2006-03-08 21:22

What did you do? Did you run the program or the script?

vlskip
New user
New user
Posts: 9
Joined: 2006-03-08 20:53

Post by vlskip » 2006-03-08 21:41

created the csv, placed in the same folder and double clicked on the script.

should i run it in another way ?

CraigHarris
Senior user
Senior user
Posts: 886
Joined: 2005-11-28 11:43

Post by CraigHarris » 2006-03-08 21:50

To run the script, run:

Code: Select all

WScript ScriptName.vbs

vlskip
New user
New user
Posts: 9
Joined: 2006-03-08 20:53

Post by vlskip » 2006-03-08 22:13

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

CraigHarris
Senior user
Senior user
Posts: 886
Joined: 2005-11-28 11:43

Post by CraigHarris » 2006-03-08 22:31

This also requires a CSV file called Users.csv in the same directory as the script
... you don't seem to have that file.

gingercat
Normal user
Normal user
Posts: 34
Joined: 2008-02-12 23:59

Re: Script to create user account?

Post by gingercat » 2008-03-26 23:29

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?

gingercat
Normal user
Normal user
Posts: 34
Joined: 2008-02-12 23:59

Re:

Post by gingercat » 2008-03-26 23:36

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

oneclicksolution
New user
New user
Posts: 2
Joined: 2007-10-06 04:22
Location: NE Ohio
Contact:

Re: Script to create user account?

Post by oneclicksolution » 2008-04-01 20:59

i'm also looking for an item like this...please let me know as well.

jjarzabek
New user
New user
Posts: 5
Joined: 2008-10-16 20:35

Re: Script to create user account?

Post by jjarzabek » 2008-10-16 20:37

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.

User avatar
martin
Developer
Developer
Posts: 6777
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Re: Script to create user account?

Post by martin » 2008-10-16 20:50

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

jjarzabek
New user
New user
Posts: 5
Joined: 2008-10-16 20:35

Re: Script to create user account?

Post by jjarzabek » 2008-10-16 21:00

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.

jjarzabek
New user
New user
Posts: 5
Joined: 2008-10-16 20:35

Re: Script to create user account?

Post by jjarzabek » 2008-10-17 17:21

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?

jjarzabek
New user
New user
Posts: 5
Joined: 2008-10-16 20:35

Re: Script to create user account?

Post by jjarzabek » 2008-10-21 15:39

Martin or anyone else? -> Best way to run this? <-

^DooM^
Site Admin
Posts: 13862
Joined: 2005-07-29 16:18
Location: UK

Re: Script to create user account?

Post by ^DooM^ » 2008-10-21 15:40

Hows about make a backup of your hMail Dir then just try it :)
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

jjarzabek
New user
New user
Posts: 5
Joined: 2008-10-16 20:35

Re: Script to create user account?

Post by jjarzabek » 2008-10-21 16:00

Very funny, but with a large list (2000+), I'd like the best practice first! :mrgreen:

User avatar
martin
Developer
Developer
Posts: 6777
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Re: Script to create user account?

Post by martin » 2008-10-21 19:02

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.

pranjut
New user
New user
Posts: 10
Joined: 2009-11-16 17:41

Re: Script to create user account?

Post by pranjut » 2009-12-30 00:10

hey guys
can anyone please tell me how can create the accounts using java???
please reply..

User avatar
mattg
Moderator
Moderator
Posts: 19716
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Script to create user account?

Post by mattg » 2009-12-30 01:34

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
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

pranjut
New user
New user
Posts: 10
Joined: 2009-11-16 17:41

Re: Script to create user account?

Post by pranjut » 2009-12-30 22:39

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....

User avatar
martin
Developer
Developer
Posts: 6777
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Re: Script to create user account?

Post by martin » 2009-12-30 22:40

pranjut,
Is it even possible to access Microsoft COM with Java?

pranjut
New user
New user
Posts: 10
Joined: 2009-11-16 17:41

Re: Script to create user account?

Post by pranjut » 2009-12-30 22:55

I've no idea.......

pranjut
New user
New user
Posts: 10
Joined: 2009-11-16 17:41

Re: Script to create user account?

Post by pranjut » 2009-12-30 22:58

is it possible that, account can be created using telnet in hmail?? if yes how, if no that's also ok...

User avatar
martin
Developer
Developer
Posts: 6777
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Re: Script to create user account?

Post by martin » 2009-12-30 23:04

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.

pranjut
New user
New user
Posts: 10
Joined: 2009-11-16 17:41

Re: Script to create user account?

Post by pranjut » 2009-12-30 23:19

thanks martin...... :)

catamarancn
New user
New user
Posts: 1
Joined: 2014-09-03 08:23

Re: Script to create user account?

Post by catamarancn » 2014-09-03 09:04

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

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: Script to create user account?

Post by percepts » 2014-09-03 13:14


Post Reply