LDAP: Bulk create mail users

Attention

Check out the lightweight on-premises email archiving software developed by iRedMail team: Spider Email Archiver.

iRedMail ships 2 scripts to help you create many mail users quickly.

Create mail users with create_mail_user_OpenLDAP.sh

# cd iRedMail-0.9.6/tools/
# bash create_mail_user_OpenLDAP.sh example.com user1 user2 user3

It will create users user1@example.com, user2@example.com, user3@example.com.

Note: you don't need to create the mail domain name example.com with iRedAdmin first.

Create mail users with create_mail_user_OpenLDAP.py

Attention

You must modify this file and update some variables related to your LDAP server (note: you can find them in iRedMail.tips file) before importing user:

While importing the generated LDIF file, you should use same BINDDN which has write privilege.

tools/create_mail_user_OpenLDAP.py reads mail accounts from a plain text file and generate a LDIF file, you can import this LDIF file later to create the mail users.

Format of the plain text file is:

domain name, username, password, [display name], [quota_in_bytes], [groups]

Note: domain name, username and password are required, others are optional.

3 examples:

mydomain.com, user1, plain_password, John Smith, 104857600, group1:group2
mydomain.com, user2, plain_password, Michael Jordan, ,
mydomain.com, user3, plain_password, , 104857600, group1:group2
cd iRedMail-1.4.2/tools/
python3 create_mail_user_OpenLDAP.py my_users.csv

It generates file my_users.csv.ldif under same directory, import it with command ldapadd to add like below to add the accounts: * Please replace cn=Manager,dc=example,dc=com by the real LDAP base dn. * Please replace my_users.csv.ldif by the file generated in above commands.

ldapadd -x -D cn=Manager,dc=example,dc=com -W -f my_users.csv.ldif

Notes:

See Also