1

Topic: Any script for deleting user?

==== Provide basic information to help troubleshoot ====
- iRedMail version: 0.7.3
- Linux/BSD distribution name and version: CentOS
- Any related log? Log is helpful for troubleshooting.
====

There's already a script called create_mail_user_OpenLDAP.sh for adding a user. Is there a script for deleting a user, including entry in LDAP and its mails? We need this tool to automate some tasks.

----

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

2

Re: Any script for deleting user?

From iRedAdmin GUI, we can delete a user there. What's the corresponding server side command?

3

Re: Any script for deleting user?

To delete a mail user stored in OpenLDAP, simply deleting user dn is not enough, removing this user's email address from others forwarding address list too. iRedAdmin-Pro, official iRedMail admin panel, will handle them all.

To delete mailbox of this user, you can find maildir path in LDAP user object, stored in attribute "homeDirectory".

4

Re: Any script for deleting user?

I modified create_mail_user_OpenLDAP.sh and used the following code to remove a user:

HOME_DIR=`ldapsearch -x -D "${BINDDN}" -w "${BINDPW}" "mail=${MAIL}"|grep homeDirectory|tail -1| awk '/ / {print $2}'`
echo  $HOME_DIR
#delete from ldap
ldapdelete -x -D "${BINDDN}" -w "${BINDPW}" "mail=${MAIL},${OU_USER_DN},${DOMAIN_DN},${BASE_DN}"
#delete home directory
rm -rf $HOME_DIR


BTW, in current version, if deleting a user from the iRedAdmin GUI, this user's maildir is not removed. It's a bug and pls fix it.

5

Re: Any script for deleting user?

csmith wrote:

BTW, in current version, if deleting a user from the iRedAdmin GUI, this user's maildir is not removed. It's a bug and pls fix it

Works as designed. Still no plan to make iRedAdmin access file system directly.

6

Re: Any script for deleting user?

ZhangHuangbin wrote:
csmith wrote:

BTW, in current version, if deleting a user from the iRedAdmin GUI, this user's maildir is not removed. It's a bug and pls fix it

Works as designed. Still no plan to make iRedAdmin access file system directly.

Doesn't sound right. If you don't delete user's directories, there will be a lot of garbage files left on disk.

7

Re: Any script for deleting user?

csmith wrote:

Doesn't sound right. If you don't delete user's directories, there will be a lot of garbage files left on disk.

Will consider write maildir path in SQL database, so that admin can delete these mailboxes manually or via cron job.

8

Re: Any script for deleting user?

Hi guys,

Just want to let you know, upcoming iRedAdmin-Pro release will log maildir path of deleted user in SQL table, so you can delete mailboxes with a script manually or with a cron job.

You can check the SQL table structure here (table name: deleted_mailboxes), let me know if you want to store more info in this table:
https://bitbucket.org/zhb/iredmail/src/ … ult#cl-283