[cvs] [Wiki] changed: RenameUsers

Wiki Guest wiki at wiki.horde.org
Sun Nov 6 17:39:31 PST 2005


guest [205.191.171.10]  Sun, 06 Nov 2005 17:39:31 -0800

Modified page: http://wiki.horde.org/RenameUsers
New Revision:  1.1
Change log:  Initial Version

@@ -1 +1,51 @@
+Sometimes there is a requirement to rename users in the Horde DB. eg: you move from a system with 'standard' users to one where virtual hosting is used. In such a situation the old user may be 'fred' and the new user may be 'fred at hisdomain.com'
 
+The script below seems to work for the following apps:
+
+* Address Book (turba)
+* Calendar (kronolith)
+* File Manager (gollem)
+* Filters (ingo)
+* Horde (horde)
+* Mail (imp)
+* News (jonah)
+* Notes (mnemo)
+* Password (passwd)
+* Tasks (nag)
+* Tickets (whups)
+* Time Tracking (hermes)
+
+YMMV and more apps will need more changes of course.
+
+**BACKUP YOU DB BEFORE RUNNING ANYTHING LIKE THIS!**
+
+<code>
+#!/bin/sh
+
+function horde_rename() {
+  new=$2; old=$1
+  echo Rename $old \-\> $new
+
+  mysql -u horde -pdocile horde << EOF
+update hermes_timeslices set employee_id = '$new' where employee_id = '$old';
+update horde_datatree set user_uid = '$new' where user_uid = '$old';
+update horde_datatree set datatree_name = '$new' where datatree_name = '$old' and user_uid = '$new';
+update horde_datatree_attributes set attribute_value = '$new' where attribute_value = '$old' and attribute_key = 'who';
+update horde_datatree_attributes set attribute_key= '$new' where attribute_key = '$old' and attribute_name = 'perm_users';
+update horde_datatree_attributes set attribute_value = '$new' where attribute_value = '$old' and attribute_name = 'owner';
+update horde_prefs set pref_uid = '$new' where pref_uid = '$old';
+update kronolith_events set event_creator_id = '$new' where event_creator_id = '$old';
+update kronolith_events set calendar_id = '$new' where calendar_id = '$old';
+update mnemo_memos set memo_owner = '$new' where memo_owner = '$old';
+update nag_tasks set task_owner = '$new' where task_owner = '$old';
+update turba_objects set owner_id = '$new' where owner_id = '$old';
+update whups_queues_users set user_uid = '$new' where user_uid = '$old';
+update whups_users_searches set user_uid = '$new' where user_uid = '$old';
+EOF
+  echo Done with $new
+}
+
+horde_rename 'fred' 'fred at hisdomain.com'
+</code>
+
+I did notice that notepads, tasks lists, calendars, etc. become 'hidden' after doing this. No data appears to be lost and users simply have to re-select the ones they want to see though.


More information about the cvs mailing list