[commits] [Wiki] changed: ImpH4Realm

Wiki Guest wikiguest at horde.org
Sat Aug 18 15:04:29 UTC 2012


guest [87.159.107.167]  Sat, 18 Aug 2012 15:04:29 +0000

Modified page: http://wiki.horde.org/ImpH4Realm
New Revision:  2
Change log:  Tweak layout

@@ -1,7 +1,7 @@
  In Horde3 with IMP4, the IMAP server configuration in  
imp/config/servers.php had a 'realm' parameter:

-<code>
+<code type="php">
  $servers['imap'] = array(
      'name' => 'IMAP Server',
      'server' => 'imap.example.com',
      'hordeauth' => false,
@@ -18,38 +18,38 @@
  The purpose of the realm parameter is to append a realm/domain to  
the Horde username after login.  For example, a user that logged into  
the server 'imap' from above with a username 'john' would have their  
Horde username set to 'john at example.com'.  This is useful if you are  
supporting multiple IMAP servers with a single Horde installation and  
the usernames in each IMAP server may overlap ('john' at server1 and  
'john' at server2 are not the same person).

  Horde4 with IMP5 does not have a native 'realm' parameter in  
imp/config/backends.local.php, but you can replicate the same  
functionality by modifying the horde 'authusername' hook.  In  
horde/config/hooks.php:

-<code>
-     public function authusername($userId, $toHorde)
-     {
-        if ($toHorde) {
-                // Get the IMAP connection object
-                $imap =  
$GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
-                // Get the IMAP hostname
-                $hostspec = $imap->ob->getParam('hostspec');
-                // Load the backends.local.php server configs
-                $servers = IMP_Imap::loadServerConfig();
-                // Look through each server for a hostname match
-                foreach ($servers as $server) {
-                        if ($server['hostspec'] == $hostspec) {
-                                // Append the 'realm' parameter
-                                $userId = $userId . '@' . $server['realm'];
-                                break;
-                        }
-                }
-                return $userId;
-        } else {
-                // strip the domain off
-                $userId = substr($userId, 0, strpos($userId, '@'));
-                return $userId;
+<code type="php">
+public function authusername($userId, $toHorde)
+{
+    if ($toHorde) {
+        // Get the IMAP connection object
+        $imap =  
$GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
+        // Get the IMAP hostname
+        $hostspec = $imap->ob->getParam('hostspec');
+        // Load the backends.local.php server configs
+        $servers = IMP_Imap::loadServerConfig();
+        // Look through each server for a hostname match
+        foreach ($servers as $server) {
+            if ($server['hostspec'] == $hostspec) {
+                // Append the 'realm' parameter
+                $userId = $userId . '@' . $server['realm'];
+                break;
+            }
          }
+        return $userId;
+    } else {
+        // strip the domain off
+        $userId = substr($userId, 0, strpos($userId, '@'));
+        return $userId;
      }
+}
  </code>

  Here is an example IMAP server config from imp/config/backends.local.php:

-<code>
+<code type="php">
  $servers['imap'] = array(
      // ENABLED by default
      'disabled' => false,
      'name' => 'IMAP Server',



More information about the commits mailing list