--- lib/Horde/Auth/kolab.php.orig       2009-04-18 12:19:03.000000000 +0200
+++ lib/Horde/Auth/kolab.php    2009-05-07 13:26:12.000000000 +0200        
@@ -165,6 +165,8 @@                                                        
      */                                                                   
     function listUsers()                                                  
     {                                                                     
+        global $conf;                                                     
+
         @include_once 'Horde/Kolab/Session.php';

         if (class_exists('Horde_Kolab_Session')) {
@@ -176,7 +178,20 @@
             $users = $server->listObjects(KOLAB_OBJECT_USER);
             $mails = array();
             foreach ($users as $user) {
-                $mails[] = $user->get(KOLAB_ATTR_MAIL);
+                if (empty($conf['kolab']['imap']['allow_special_users'])) {
+                    $mails[] = $user->get(KOLAB_ATTR_MAIL);
+                } else {
+                    $uid = $user->get(KOLAB_ATTR_UID);
+                    if (isset($conf['kolab']['server']['deny_group'])) {
+                        if (!$server->memberOfGroupAddress($uid, $conf['kolab']['server']['deny_group'])) {
+                            $mails[] = $user->get(KOLAB_ATTR_MAIL);
+                        }
+                    } else if (isset($conf['kolab']['server']['allow_group'])) {
+                        if ($server->memberOfGroupAddress($uid, $conf['kolab']['server']['allow_group'])) {
+                            $mails[] = $user->get(KOLAB_ATTR_MAIL);
+                        }
+                    }
+                }
             }
             return $mails;
         } else {