2016-05-19 06:51:20 -05:00
<!DOCTYPE html>
2015-09-28 21:42:47 -05:00
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" / >
< title > LDAP: Bulk create mail users< / title >
< link rel = "stylesheet" type = "text/css" href = "./css/markdown.css" / >
< / head >
< body >
< div id = "navigation" >
2016-04-19 12:48:51 -05:00
< a href = "/index.html" target = "_blank" >
< img alt = "iRedMail web site"
src="./images/logo-iredmail.png"
style="vertical-align: middle; height: 30px;"
/>
< span > iRedMail< / span >
< / a >
2016-02-29 02:15:19 -06:00
// < a href = "./index.html" > Document Index< / a > < / div > < h1 id = "ldap-bulk-create-mail-users" > LDAP: Bulk create mail users< / h1 >
2015-09-28 21:42:47 -05:00
< p > iRedMail ships 2 scripts to help you create many mail users quickly.< / p >
< ul >
< li > < code > tools/create_mail_user_OpenLDAP.sh< / code > (shell script) will connect to LDAP
server and add accounts directly.< / li >
< li > < code > tools/create_mail_user_OpenLDAP.py< / code > (Python script) will read mail accounts
from a plain text file and generate a LDIF file, you can import this LDIF
file to create mail users.< / li >
< / ul >
2016-10-23 09:27:06 -05:00
< h2 id = "create-mail-users-with-create_mail_user_openldapsh" > Create mail users with create_mail_user_OpenLDAP.sh< / h2 >
2015-09-28 21:42:47 -05:00
< ul >
< li >
< p > Open this script and update some variables related to your LDAP server (note:
you can find them in < code > iRedMail.tips< / code > file):< / p >
< ul >
< li > < code > LDAP_SUFFIX< / code > : the ldap suffix of your OpenLDAP server. default is
< code > dc=example,dc=com< / code > < / li >
< li > < code > BINDPW< / code > : password of LDAP root dn (< code > cn=Manager,dc=example,dc=com< / code > ).< / li >
< / ul >
< p > Notes:< / p >
< ul >
< li > Default password is same as username. if you prefer to set a password for all
created users, please open the script and update variable < code > DEFAULT_PASSWD< / code >
with new password and set < code > USE_DEFAULT_PASSWD='YES'< / code > .< / li >
< li > Password scheme is defined in variable < code > PASSWORD_SCHEME< / code > (or < code > CRYPT_MECH< / code > in
old iRedMail releases), default is < code > SSHA< / code > .< / li >
< li > Per-user mailbox quota is defined in variable < code > QUOTA< / code > , default is
< code > 1048576000< / code > (100 MB, equals to 100 * 1024 * 1024).< / li >
< li > Maildir path is hashed like < code > domain.ltd/u/s/e/username-20150929< / code > . If you
prefer < code > domain.ltd/username/< / code > , please set < code > MAILDIR_STYLE='normal'< / code > .< / li >
< li > Mailbox storage path is defined in variable < code > STORAGE_BASE_DIRECTORY< / code > , default
is < code > /var/vmail/vmail1< / code > .< / li >
< / ul >
< / li >
< li >
< p > Create mail users:< / p >
< / li >
< / ul >
< pre > < code class = "shell" > # cd iRedMail-0.9.2/tools/
# bash create_mail_user_OpenLDAP.sh example.com user1 user2 user3
< / code > < / pre >
< p > It will create users < code > user1@example.com< / code > , < code > user2@example.com< / code > , < code > user3@example.com< / code > .< / p >
< p > Note: you don't need to create the mail domain name < code > example.com< / code > with iRedAdmin first.< / p >
2016-10-23 09:27:06 -05:00
< h2 id = "create-mail-users-with-create_mail_user_openldappy" > Create mail users with create_mail_user_OpenLDAP.py< / h2 >
2015-09-28 21:42:47 -05:00
< p > < code > tools/create_mail_user_OpenLDAP.py< / code > will read mail accounts from a plain
text file and generate a LDIF file, you can import this LDIF file to create
mail users.< / p >
< p > The plain text file format is:< / p >
< pre > < code > domain name, username, password, [common name], [quota_in_bytes], [groups]
< / code > < / pre >
< p > Note: domain name, username and password are < strong > required< / strong > , others are optional.< / p >
< ul >
< li > < strong > username< / strong > : do not append < code > @domain.com< / code > part in username.< / li >
< li > < strong > common name< / strong > :< ul >
< li > It will be the same as username if it's empty.< / li >
< li > Non-ascii character is allowed in this field, they will be
encoded automaticly. Such as Chinese, Korea, Japanese, etc.< / li >
< / ul >
< / li >
< li > < strong > quota< / strong > : It will be 0 (unlimited quota) if it's empty.< / li >
< li > < strong > groups< / strong > :< ul >
< li > user will become member of specified groups.< / li >
< li > it must be valid group names without < code > @domain.com< / code > part. for example,
use < code > support< / code > for group < code > support@domain.com< / code > . The < code > @domain.com< / code > part
will be appended automaticly.< / li >
< li > Multiple groups must be seperated by colon < code > :< / code > .< / li >
< / ul >
< / li >
< li > Leading and trailing Space will be ignored.< / li >
< / ul >
< p > 3 examples:< / p >
< pre > < code > 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
< / code > < / pre >
< ul >
< li > Now create mail domain < code > mydomain.com< / code > with iRedAdmin first.< / li >
< li > Run this script with plain text file < code > my_users.csv< / code > :< / li >
< / ul >
< pre > < code > # cd iRedMail-0.9.2/tools/
# python create_mail_user_OpenLDAP.py my_users.csv
< / code > < / pre >
< p > It will generate a plain LDIF file < code > my_users.csv.ldif< / code > under current directory,
you can import it (after reviewed the LDIF data) with command < code > ldapadd< / code > like
below:< / p >
< pre > < code > # ldapadd -x -D cn=Manager,dc=example,dc=com -W -f the_output_file.ldif
< / code > < / pre >
< p > Notes:< / p >
< ul >
< li > Please replace < code > cn=Manager,dc=example,dc=com< / code > by the real LDAP root dn.< / li >
< li > Please replace < code > the_output_file.ldif< / code > by the real output file.< / li >
< / ul >
< p > Additional Notes:< / p >
< ul >
< li > Password scheme is defined in variable < code > DEFAULT_PASSWORD_SCHEME< / code > , default is
< code > SSHA< / code > .< / li >
< li > Maildir path is hashed like < code > domain.ltd/u/s/e/username-20150929< / code > . If you
prefer < code > domain.ltd/username/< / code > , please set < code > HASHED_MAILDIR = False< / code > .< / li >
< li > Mailbox storage path is defined in variable < code > STORAGE_BASE_DIRECTORY< / code > , default
is < code > /var/vmail/vmail1< / code > .< / li >
< / ul >
< h2 id = "see-also" > See Also< / h2 >
< ul >
< li > < a href = "./sql.bulk.create.mail.users.html" > SQL: Bulk create mail users< / a > < / li >
2016-05-19 06:51:20 -05:00
< / ul > < div class = "footer" >
< p style = "text-align: center; color: grey;" > All documents are available in < a href = "https://bitbucket.org/zhb/iredmail-docs/src" > BitBucket repository< / a > , and published under < a href = "http://creativecommons.org/licenses/by-nd/3.0/us/" target = "_blank" > Creative Commons< / a > license. You can < a href = "https://bitbucket.org/zhb/iredmail-docs/get/tip.tar.bz2" > download the latest version< / a > for offline reading. If you found something wrong, please do < a href = "http://www.iredmail.org/contact.html" > contact us< / a > to fix it.< / p >
< / div >
< script type = "text/javascript" >
2015-09-28 21:42:47 -05:00
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-3293801-21', 'auto');
ga('send', 'pageview');
< / script >
< / body > < / html >