1

Topic: Call for testers: Bulk add/import LDAP mail users

Hi, all.

We've created a new script tool for adding/importing LDAP mail users, please help to test. Patches/suggestions are always welcome smile

Download script here:
http://iredmail.googlecode.com/svn/trun … penLDAP.py

We wrote this script with Python, so that it can handle non-ASCII characters, such as Chinese, Korea, Japanese, etc.

Usage:

* Install python first:

  If you have iRedMail installed, it should be ready. If not, you can install it like this:

  - RHEL/CentOS: # yum install python
  - Debian/Ubuntu: # sudo apt-get install python

- Install python module: python-ldap.

  - RHEL/CentOS: # yum install python-ldap
  - Debian/Ubuntu: # sudo apt-get install python-ldap

- Write down or export your user accounts in a CSV format plain text file, e.g. users.csv.

  You can execute the script directly to get file format example:

  $ python create_mail_user_OpenLDAP.py

- Execute the script to convert CSV file to LDIF format:

  $ python create_mail_user_OpenLDAP.py users.csv

  It will generate a new file 'users.csv.ldif'.

- User ldapadd command or phpLDAPadmin to import this LDIF file.

Note: Currently, it only support 5 fields:
* Domain name
* Username (userpart in email address)
* Password
* Command name (cn)
* Mail quota

If you need to support more fields, please reply below with more details.

Thanks for your test and feedback smile

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Call for testers: Bulk add/import LDAP mail users

Got feedback from one user:

  • [DONE] Add group info (memberOfGroup).

3

Re: Call for testers: Bulk add/import LDAP mail users

Is there a bulk add/import feature for non LDAP users? I would like to add many users and I don't want to have to add them separately. Thanks in advance.

4

Re: Call for testers: Bulk add/import LDAP mail users

Do you mean tools/create_mail_user_MySQL.sh?
Open it and read the head lines for usage, but it's not so smart yet.

5

Re: Call for testers: Bulk add/import LDAP mail users

Assume! Thank you. That was exactly what I needed.

6

Re: Call for testers: Bulk add/import LDAP mail users

Hi,

a small bug :

line 161 , should be :
mailMessageStore = maildir_domain + "/" + maildir_user


Rgds

7

Re: Call for testers: Bulk add/import LDAP mail users

Another issue :
if i want to specify the quota, it takes automatically 1024, which is wrong ,
the script does not use my value

see :
if quota == '':
        quota = '0'
    else:
        quota = '1024'

8

Re: Call for testers: Bulk add/import LDAP mail users

Hi, saidmsl.

Fixed: http://code.google.com/p/iredmail/sourc … 80663d56e3

Thanks for your testing and report. smile

9 (edited by hata_ph 2011-05-12 11:59:36)

Re: Call for testers: Bulk add/import LDAP mail users

I am testing create_mail_user_OpenLDAP.py for iRedMail-0.7.1 and notice a few problem. Below is my adjustment.

STORAGE_BASE_DIRECTORY = '/var/vmail'

mailMessageStore = 'vmail1/' + maildir_domain + '/' + maildir_user

similar adjustment have to done on create_mail_user_OpenLDAP.sh too...

ZhangHuangbin wrote:

Got feedback from one user:

  • [DONE] Add group info (memberOfGroup).

BTW, what should i put for the group option in my xxx.csv file?

10

Re: Call for testers: Bulk add/import LDAP mail users

hata_ph wrote:

BTW, what should i put for the group option in my xxx.csv file?

When you execute "python tools/create_mail_user_OpenLDAP.py", it will print help message:

CSV file format:

    domain name, username, password, [common name], [quota], [groups]

Example #1:
    iredmail.org, zhang, secret_pw, Zhang Huangbin, 1024, group1:group2
Example #2:
    iredmail.org, zhang, secret_pw, Zhang Huangbin, , ,
Example #3:
    iredmail.org, zhang, secret_pw, , 1024, group1:group2

Note: group1, group1 must not be a email addresses, because script will append '@[domain.ltd]' automatically.

11

Re: Call for testers: Bulk add/import LDAP mail users

So what group should i put?
vmail?

12

Re: Call for testers: Bulk add/import LDAP mail users

hata_ph wrote:

So what group should i put?

The groups is mail addresses of mail list. For example, if you want to assign user "user@domain.ltd" to two mail lists: list01@domain.ltd, list02@domain.ltd, then groups must be: list01,list02

13

Re: Call for testers: Bulk add/import LDAP mail users

I don't use mailing list and i cannot leave it empty...default should be?

14

Re: Call for testers: Bulk add/import LDAP mail users

As i mentioned in above post, you can leave it empty:

Example #2:
    iredmail.org, zhang, secret_pw, Zhang Huangbin, , ,

15

Re: Call for testers: Bulk add/import LDAP mail users

if i leave the groups value blank in my CVS file it will show below error

Traceback (most recent call last):
File "create_mail_user_OpenLDAP.py", line 207, in ?
domain, username, passwd, cn, quota, groups = re.split('\s?,\s?, entry)
ValueError: too many valuesto unpack

16

Re: Call for testers: Bulk add/import LDAP mail users

Could you create a new forum topic and show some samples of your CSV file? You can REPLACE the real domain name, username, password before posting.

17

Re: Call for testers: Bulk add/import LDAP mail users

ZhangHuangbin wrote:

Could you create a new forum topic and show some samples of your CSV file? You can REPLACE the real domain name, username, password before posting.

The problem is there is a extra comma in the csv file. Remove it and it work. It should have 5 comma instead of 6.

xxx.org, wong, wong, wong, ,