<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.qmailtoaster.org:80/index.php?action=history&amp;feed=atom&amp;title=Account_Creation_and_Deletion_Date</id>
	<title>Account Creation and Deletion Date - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.qmailtoaster.org:80/index.php?action=history&amp;feed=atom&amp;title=Account_Creation_and_Deletion_Date"/>
	<link rel="alternate" type="text/html" href="http://wiki.qmailtoaster.org:80/index.php?title=Account_Creation_and_Deletion_Date&amp;action=history"/>
	<updated>2026-04-08T07:54:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>http://wiki.qmailtoaster.org:80/index.php?title=Account_Creation_and_Deletion_Date&amp;diff=132&amp;oldid=prev</id>
		<title>Ebroch: Created page with &quot;== Background == My Helpdesk was audited by external auditor regarding date of creation and deletion of email accounts. I can&#039;t find it the exact date by looking /home/vpopmail folders. So I ask the community and Bharath Chari kind enough to provide the tweaks.  == Notes == # Use this tips with qmailtoaster&#039;s version &gt;= vpopmail-5.4.17 with mysql backend (not LDAP). # Use only with MySQL version 5.0 or newer which has trigger feature. # This trigger only work with vpopma...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.qmailtoaster.org:80/index.php?title=Account_Creation_and_Deletion_Date&amp;diff=132&amp;oldid=prev"/>
		<updated>2024-03-16T16:27:48Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Background == My Helpdesk was audited by external auditor regarding date of creation and deletion of email accounts. I can&amp;#039;t find it the exact date by looking /home/vpopmail folders. So I ask the community and Bharath Chari kind enough to provide the tweaks.  == Notes == # Use this tips with qmailtoaster&amp;#039;s version &amp;gt;= vpopmail-5.4.17 with mysql backend (not LDAP). # Use only with MySQL version 5.0 or newer which has trigger feature. # This trigger only work with vpopma...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Background ==&lt;br /&gt;
My Helpdesk was audited by external auditor regarding date of creation and deletion of email accounts. I can&amp;#039;t find it the exact date by looking /home/vpopmail folders. So I ask the community and Bharath Chari kind enough to provide the tweaks.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
# Use this tips with qmailtoaster&amp;#039;s version &amp;gt;= vpopmail-5.4.17 with mysql backend (not LDAP).&lt;br /&gt;
# Use only with MySQL version 5.0 or newer which has trigger feature.&lt;br /&gt;
# This trigger only work with vpopmail with --disable-many-domains (each domain has it&amp;#039;s own table). &lt;br /&gt;
# In the future, perhaps Bharath will make a script available via QTP to do this automatically, so you no longer need to follow the steps below.&lt;br /&gt;
# These steps are based on [http://www.mail-archive.com/qmailtoaster-list@qmailtoaster.com/msg33054.html email sent by Bharath Chari to QMailToaster&amp;#039;s list].&lt;br /&gt;
# MAKE BACKUP of vpopmail database before you do these steps.&lt;br /&gt;
&lt;br /&gt;
== Steps ==&lt;br /&gt;
Assumption: Domain to be monitored is example.com and the domain table is example_com.&lt;br /&gt;
&lt;br /&gt;
1) Log in to mysql shell as root&lt;br /&gt;
&lt;br /&gt;
 mysql -uroot -p vpopmail&lt;br /&gt;
&lt;br /&gt;
2) Alter the example_com table (replace example_com with your domain table)&lt;br /&gt;
&lt;br /&gt;
 ALTER TABLE `example_com` DROP PRIMARY KEY;&lt;br /&gt;
 ALTER TABLE `example_com` ADD UNIQUE (`pw_name`);&lt;br /&gt;
 ALTER TABLE `example_com` ADD `uid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST ;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3) Create log table - replace example_com with your domain table name&lt;br /&gt;
&lt;br /&gt;
 CREATE TABLE `userlog_example_com` (&lt;br /&gt;
  `uid` int(11) NOT NULL,&lt;br /&gt;
  `pw_name` varchar(255) NOT NULL,&lt;br /&gt;
  `creation_date` datetime NOT NULL default &amp;#039;0000-00-00 00:00:00&amp;#039;,&lt;br /&gt;
  `deletion_date` datetime NOT NULL default &amp;#039;0000-00-00 00:00:00&amp;#039;,&lt;br /&gt;
  PRIMARY KEY  (`uid`)&lt;br /&gt;
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4) Import existing records into the userlog_example_com table. While this won&amp;#039;t help with creation date, it will allow you to track when an ID was deleted:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt;insert into userlog_example_com (uid,pw_name) select uid,pw_name from example_com;&lt;br /&gt;
&lt;br /&gt;
5) Create the INSERT Trigger (again replace example_com as appropriate)&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; delimiter $$&lt;br /&gt;
 mysql&amp;gt; create trigger example_com_insert_trigger&lt;br /&gt;
     -&amp;gt; AFTER insert on example_com&lt;br /&gt;
     -&amp;gt; FOR EACH ROW&lt;br /&gt;
     -&amp;gt; BEGIN&lt;br /&gt;
&lt;br /&gt;
     -&amp;gt; insert into userlog_example_com values(new.uid,new.pw_name,NOW(),&amp;#039;0000-00-00 00:00:00&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
     -&amp;gt; END$$&lt;br /&gt;
 Query OK, 0 rows affected (0.02 sec)&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; delimiter ;&lt;br /&gt;
&lt;br /&gt;
6) Create the DELETE Trigger (again replace example_com as appropriate)&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; delimiter $$&lt;br /&gt;
 mysql&amp;gt; CREATE TRIGGER example_com_delete_trigger&lt;br /&gt;
    -&amp;gt; AFTER delete on example_com&lt;br /&gt;
    -&amp;gt; FOR EACH ROW&lt;br /&gt;
    -&amp;gt; BEGIN&lt;br /&gt;
&lt;br /&gt;
    -&amp;gt; update userlog_example_com set deletion_date=NOW() where uid=old.uid;&lt;br /&gt;
&lt;br /&gt;
    -&amp;gt; END$$&lt;br /&gt;
 Query OK, 0 rows affected (0.02 sec)&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; delimiter ;&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt;quit&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7) Test and test again:&lt;br /&gt;
Create a test user eg : xxxxx using qmailadmin&lt;br /&gt;
Delete the user xxxxx&lt;br /&gt;
Create the test user xxxxx again&lt;br /&gt;
Delete the user xxxxx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Your table userlog_example_com should contain two records both with xxxxx as the pw_name but with different uid numbers and creation/deletion dates.&lt;/div&gt;</summary>
		<author><name>Ebroch</name></author>
	</entry>
</feed>