iredmail-doc/html_bk/ldap.bulk.create.mail.users...

134 lines
6.7 KiB
HTML

<!DOCTYPE html>
<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">
<a href="https://www.iredmail.org" target="_blank">
<img alt="iRedMail web site"
src="./images/logo-iredmail.png"
style="vertical-align: middle; height: 30px;"
/>&nbsp;
<span>iRedMail</span>
</a>
&nbsp;&nbsp;//&nbsp;&nbsp;<a href="./index.html">Document Index</a></div><h1 id="ldap-bulk-create-mail-users">LDAP: Bulk create mail users</h1>
<div class="toc">
<ul>
<li><a href="#ldap-bulk-create-mail-users">LDAP: Bulk create mail users</a><ul>
<li><a href="#create-mail-users-with-create_mail_user_openldapsh">Create mail users with create_mail_user_OpenLDAP.sh</a></li>
<li><a href="#create-mail-users-with-create_mail_user_openldappy">Create mail users with create_mail_user_OpenLDAP.py</a></li>
<li><a href="#see-also">See Also</a></li>
</ul>
</li>
</ul>
</div>
<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>
<h2 id="create-mail-users-with-create_mail_user_openldapsh">Create mail users with create_mail_user_OpenLDAP.sh</h2>
<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>104857600</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="language-shell"># cd iRedMail-0.9.6/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>
<h2 id="create-mail-users-with-create_mail_user_openldappy">Create mail users with create_mail_user_OpenLDAP.py</h2>
<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.6/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>
</ul><div class="footer">
<p style="text-align: center; color: grey;">All documents are available in <a href="https://github.com/iredmail/docs/">GitHub 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://github.com/iredmail/docs/archive/master.zip">download the latest version</a> for offline reading. If you found something wrong, please do <a href="https://www.iredmail.org/contact.html">contact us</a> to fix it.</p>
</div></body></html>