Can I modify iRedAdmin-Pro LDAP code to access filesystem and remove folders?
Please, point out which file/files should be modified. I'm not a Python geek, but understand MVC architecture and can code...
Alright, here we go:
*) WARNING: Please test your code on a testing machine first, don't do it on production server directly. Removed mailboxes CAN NOT be restored.
*) We're taking the latest iRedAdmin-Pro-LDAP-1.6.3 for example. If you haven't upgraded to 1.6.3, please upgrade it as soon as possible.
*) Open file libs/ldaplib/user.py, find function 'deleteSingleUser()', about line 328:
# Delete single user.
def deleteSingleUser(self, mail, deleteFromGroups=True,):
# Delete object and its subtree.
deltree.DelTree(self.conn, self.dnUser, ldap.SCOPE_SUBTREE)
What you need to do are:
*) Query LDAP server to get maildir path of this mail user.
*) Delete the whole maildir directory. Note: It will execute command as user 'iredadmin' and group 'iredadmin' by default, so please make sure this user/group can access mailbox directory (/var/vmail by default).
All your code MUST be placed ABOVE line 'deltree.DelTree()' i paste above.
To delete whole mailbox directory, you can use Python module 'os'. For example: