<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[iRedMail — Remove mailboxes when deleting user]]></title>
	<link rel="self" href="http://www.iredmail.org/forum/feed-atom-topic2853.xml" />
	<updated>2012-11-06T19:12:16Z</updated>
	<generator>PunBB</generator>
	<id>http://www.iredmail.org/forum/topic2853-remove-mailboxes-when-deleting-user.html</id>
		<entry>
			<title type="html"><![CDATA[Re: Remove mailboxes when deleting user]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post18991.html#p18991" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>maltamirano wrote:</cite><blockquote><p>Thanks for you quick reply!<br />Will folow your directions ASAP and post back results.</p><p>Regards,<br />Martin.</p></blockquote></div><p>Did you ever get this working?</p><p>I completely agree that iredadmin does not delete the user files straight away when a user gets deleted.<br />But I also see how this can become a big issue on small filesystems. So I would suggest a compromise using a daily cron job which delete user email directory if it no longer exists in the databae.<br />- For security this would save the users email directory for 30 days by:<br />1. When it first notices that the user no longer exists in the DB write a file with the current date or using a counter which gets decremented each day.<br />2. For each &quot;deleted user&quot; this date is then compared to the CURRENT_DATE and if it is more then 30 days delete the directory.</p><p>This keeps everybody happy :-)</p>]]></content>
			<author>
				<name><![CDATA[web2works]]></name>
				<uri>http://www.iredmail.org/forum/user2175.html</uri>
			</author>
			<updated>2012-11-06T19:12:16Z</updated>
			<id>http://www.iredmail.org/forum/post18991.html#p18991</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Remove mailboxes when deleting user]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post13376.html#p13376" />
			<content type="html"><![CDATA[<p>Thanks for you quick reply!<br />Will folow your directions ASAP and post back results.</p><p>Regards,<br />Martin.</p>]]></content>
			<author>
				<name><![CDATA[maltamirano]]></name>
				<uri>http://www.iredmail.org/forum/user20654.html</uri>
			</author>
			<updated>2012-01-17T16:16:12Z</updated>
			<id>http://www.iredmail.org/forum/post13376.html#p13376</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Remove mailboxes when deleting user]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post13357.html#p13357" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>maltamirano wrote:</cite><blockquote><p>Can I modify iRedAdmin-Pro LDAP code to access filesystem and remove folders?<br />Please, point out which file/files should be modified. I&#039;m not a Python geek, but understand MVC architecture and can code...</p></blockquote></div><p>Alright, here we go:</p><p>*) WARNING: Please test your code on a testing machine first, don&#039;t do it on production server directly. Removed mailboxes CAN NOT be restored.<br />*) We&#039;re taking the latest iRedAdmin-Pro-LDAP-1.6.3 for example. If you haven&#039;t upgraded to 1.6.3, please upgrade it as soon as possible.<br />*) Open file libs/ldaplib/user.py, find function &#039;deleteSingleUser()&#039;, about line 328:<br /></p><div class="codebox"><pre><code>    # Delete single user.
    def deleteSingleUser(self, mail, deleteFromGroups=True,):
        ...

        try:
            ...
            # Delete object and its subtree.
            deltree.DelTree(self.conn, self.dnUser, ldap.SCOPE_SUBTREE)
        ...</code></pre></div><p>What you need to do are:</p><p>*) Query LDAP server to get maildir path of this mail user.<br />*) Delete the whole maildir directory. Note: It will execute command as user &#039;iredadmin&#039; and group &#039;iredadmin&#039; by default, so please make sure this user/group can access mailbox directory (/var/vmail by default).</p><p>All your code MUST be placed ABOVE line &#039;deltree.DelTree()&#039; i paste above.<br />To delete whole mailbox directory, you can use Python module &#039;os&#039;. For example:<br /></p><div class="codebox"><pre><code>import os
os.removedirs(&#039;/tmp/test_dir/&#039;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2012-01-17T04:46:50Z</updated>
			<id>http://www.iredmail.org/forum/post13357.html#p13357</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Remove mailboxes when deleting user]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post13352.html#p13352" />
			<content type="html"><![CDATA[<p>Even though this request has been posted (and answered) more than once, I will insist in getting some solution:<br />I need the filesystem mailbox folder automatically deleted while removing a user from iRedAdmin-Pro LDAP UI. Maybe this is about to be addressed in the near(?) future, but some kind of help is needed meanwhile.</p><p>Can I modify iRedAdmin-Pro LDAP code to access filesystem and remove folders?<br />Please, point out which file/files should be modified. I&#039;m not a Python geek, but understand MVC architecture and can code...</p><p>Regards, Martin.</p>]]></content>
			<author>
				<name><![CDATA[maltamirano]]></name>
				<uri>http://www.iredmail.org/forum/user20654.html</uri>
			</author>
			<updated>2012-01-16T20:40:17Z</updated>
			<id>http://www.iredmail.org/forum/post13352.html#p13352</id>
		</entry>
</feed>
