--- cyrsql.php.orig	2008-06-25 19:24:38.000000000 +0300
+++ cyrsql.php	2008-06-25 21:40:52.000000000 +0300
@@ -200,7 +200,8 @@
                              $this->_params['table'],
                              $this->_params['username_field'],
                              $this->_params['domain_field']);
-            $values = explode('@', $userId);
+            list($name, $domain) = explode('@', $userId);
+            $values = array($userId, $domain);
         } else {
             /* Build the SQL query without domain. */
             $query = sprintf('SELECT * FROM %s WHERE %s = ?',
@@ -272,7 +273,7 @@
                              $this->_params['username_field'],
                              $this->_params['domain_field'],
                              $this->_params['password_field']);
-            $values = array($name,
+            $values = array($userId,
                             $domain,
                             $this->getCryptedPassword($credentials['password'],
                                                       '',
@@ -283,7 +284,7 @@
 
             $dbresult = $this->_db->query($query, $values);
             $query = 'INSERT INTO virtual (alias, dest, username, status) VALUES (?, ?, ?, 1)';
-            $values = array($userId, $userId, $name);
+            $values = array($userId, $userId, $userId);
 
             Horde::logMessage('SQL Query by Auth_cyrsql::addUser(): ' . $query, __FILE__, __LINE__, PEAR_LOG_DEBUG);
 
@@ -339,7 +340,7 @@
                              $this->_params['table'],
                              $this->_params['username_field'],
                              $this->_params['domain_field']);
-            $values = array($name, $domain);
+            $values = array($userId, $domain);
 
             Horde::logMessage('SQL Query by Auth_cyrsql::removeUser(): ' . $query, __FILE__, __LINE__, PEAR_LOG_DEBUG);
 
@@ -411,7 +412,7 @@
             && ($this->_params['domain_field'] != 'none')) {
             foreach ($result as $ar) {
                 if (!in_array($ar[0], $this->_params['hidden_accounts'])) {
-                    $users[] = $ar[0] . '@' . $ar[1];
+                    $users[] = $ar[0];
                 }
             }
         } else {
@@ -453,7 +454,7 @@
                                                       '',
                                                       $this->_params['encryption'],
                                                       $this->_params['show_encryption']),
-                            $name, $domain);
+                            $oldID, $domain);
         } else {
             /* Build the SQL query. */
             $query = sprintf('UPDATE %s SET %s = ? WHERE %s = ?',
