\documentclass{article}
\usepackage{ulem}
\usepackage{graphicx}
\usepackage{hyperref}
\pagestyle{headings}
\begin{document}
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.

<pre><code class="language-sql">
-- 
-- 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;
</code></pre>
\end{document}
