6.0.0-git
2024-04-16
Last Modified 2008-07-16 by Guest

The below SQL code can be used to rename the realm for all users or remove the realm from the uid's.

You probably want to tweak the SELECT statement for creating the temporary table in order to change the realm to what you need. You'll also want to compare the update statements to make sure they match all the tables in your Horde install. The update statements below are applicable to the Horde Groupware Webmail Edition.

-- 
-- realm_change.sql
--
-- This SQL code will change all the horde users from user@example.com to user.
--

CREATE TEMPORARY TABLE hu AS
SELECT DISTINCT pref_uid AS olduid, SUBSTRING_INDEX( pref_uid, '@', 1 ) AS newuid
FROM horde_prefs
WHERE pref_uid LIKE "%@example.com";

update hu, horde_alarms set alarm_uid = hu.newuid where alarm_uid = hu.olduid;
update hu, horde_datatree set user_uid = hu.newuid where user_uid = hu.olduid;
update hu, horde_datatree set datatree_name = hu.newuid where datatree_name = hu.olduid and user_uid = hu.newuid;
update hu, horde_datatree_attributes set attribute_value = hu.newuid where attribute_value = hu.olduid and attribute_key = 'who';
update hu, horde_datatree_attributes set attribute_key = hu.newuid where attribute_key = hu.olduid and attribute_name = 'perm_users';
update hu, horde_datatree_attributes set attribute_value = hu.newuid where attribute_value = hu.olduid and attribute_name = 'uid';
update hu, horde_datatree_attributes set attribute_value = hu.newuid where attribute_value = hu.olduid and attribute_name = 'owner';
update hu, horde_histories set history_who = hu.newuid where history_who = hu.olduid;
update hu, horde_prefs set pref_uid = hu.newuid where pref_uid = hu.olduid;
update hu, horde_syncml_anchors set syncml_uid = hu.newuid where syncml_uid = hu.olduid;
update hu, horde_syncml_map set syncml_uid = hu.newuid where syncml_uid = hu.olduid;
update hu, ingo_forwards set forward_owner = hu.newuid where forward_owner = hu.olduid;
update hu, ingo_lists set list_owner = hu.newuid where list_owner = hu.olduid;
update hu, ingo_rules set rule_owner = hu.newuid where rule_owner = hu.olduid;
update hu, ingo_shares set share_owner = hu.newuid where share_owner = hu.olduid;
update hu, ingo_shares set perm_creator = hu.newuid where perm_creator = hu.olduid;
update hu, ingo_shares_users set user_uid = hu.newuid where user_uid = hu.olduid;
update hu, ingo_spam set spam_owner = hu.newuid where spam_owner = hu.olduid;
update hu, ingo_vacations set vacation_owner = hu.newuid where vacation_owner = hu.olduid;
update hu, kronolith_events set event_creator_id = hu.newuid where event_creator_id = hu.olduid;
update hu, kronolith_events set calendar_id = hu.newuid where calendar_id = hu.olduid;
update hu, kronolith_shares set share_owner = hu.newuid where share_owner = hu.olduid;
update hu, kronolith_shares set perm_creator = hu.newuid where perm_creator = hu.olduid;
update hu, kronolith_shares_users set user_uid = hu.newuid where user_uid = hu.olduid;
update hu, mnemo_memos set memo_owner = hu.newuid where memo_owner = hu.olduid;
update hu, nag_tasks set task_owner = hu.newuid where task_owner = hu.olduid;
update hu, turba_objects set owner_id = hu.newuid where owner_id = hu.olduid;