--- SoObjects/Mailer/SOGoMailFolder.m	old
+++ SoObjects/Mailer/SOGoMailFolder.m	new
@@ -943,6 +943,15 @@
   return imapAcls;
 }
 
+- (NSString *) _sogoAclUidToImapUid: (NSString *) uid
+{
+  if ([uid hasPrefix: @"@"])
+    return [[[[context activeUser] domainDefaults] imapAclGroupIdPrefix]
+             stringByAppendingString: [uid substringFromIndex: 1]];
+  else
+    return uid;
+}
+
 - (void) _removeIMAPExtUsernames
 {
   NSMutableDictionary *newIMAPAcls;
@@ -963,6 +972,32 @@
   mailboxACL = newIMAPAcls;
 }
 
+- (void) _convertIMAPGroupnames
+{
+  NSMutableDictionary *newIMAPAcls;
+  NSEnumerator *usernames;
+  NSString *username;
+  NSString *newUsername;
+  NSString *imapPrefix;
+
+  imapPrefix = [[[context activeUser] domainDefaults] imapAclGroupIdPrefix];
+
+  newIMAPAcls = [NSMutableDictionary new];
+
+  usernames = [[mailboxACL allKeys] objectEnumerator];
+  while ((username = [usernames nextObject]))
+    {
+      if ([username hasPrefix: imapPrefix])
+        newUsername = [@"@" stringByAppendingString: [username substringFromIndex: [imapPrefix length]]];
+      else
+        newUsername = username;
+      [newIMAPAcls setObject: [mailboxACL objectForKey: username]
+		   forKey: newUsername];
+    }
+  [mailboxACL release];
+  mailboxACL = newIMAPAcls;
+}
+
 - (void) _readMailboxACL
 {
   [mailboxACL release];
@@ -970,6 +1005,7 @@
   mailboxACL = [[self imap4Connection] aclForMailboxAtURL: [self imap4URL]];
   [mailboxACL retain];
 
+  [self _convertIMAPGroupnames];
   if ([[self mailAccountFolder] imapAclConformsToIMAPExt])
     [self _removeIMAPExtUsernames];
 }
@@ -1061,7 +1097,7 @@
 
   uids = [users objectEnumerator];
   while ((currentUID = [uids nextObject]))
-    [client deleteACL: folderName uid: currentUID];
+    [client deleteACL: folderName uid: [self _sogoAclUidToImapUid: currentUID]];
   [mailboxACL release];
   mailboxACL = nil;
 }
@@ -1073,7 +1109,7 @@
 
   acls = [self _sogoAclsToImapAcls: roles];
   folderName = [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]];
-  [[imap4 client] setACL: folderName rights: acls uid: uid];
+  [[imap4 client] setACL: folderName rights: acls uid: [self _sogoAclUidToImapUid: uid]];
 
   [mailboxACL release];
   mailboxACL = nil;
--- SoObjects/SOGo/SOGoDefaults.plist	old
+++ SoObjects/SOGo/SOGoDefaults.plist	new
@@ -5,6 +5,7 @@
     WOPidFile = "/var/run/sogo/sogo.pid";
 
     NGImap4ConnectionStringSeparator = "/";
+    NGImap4ConnectionGroupIdPrefix = "$";
     NGImap4DisableIMAP4Pooling = YES;
 
     SOGoZipPath = "/usr/bin/zip";
--- SoObjects/SOGo/SOGoDomainDefaults.h	old
+++ SoObjects/SOGo/SOGoDomainDefaults.h	new
@@ -43,6 +43,7 @@
 - (NSString *) imapServer;
 - (NSString *) sieveServer;
 - (NSString *) imapAclStyle;
+- (NSString *) imapAclGroupIdPrefix;
 - (NSString *) imapFolderSeparator;
 - (BOOL) imapAclConformsToIMAPExt;
 - (BOOL) forceIMAPLoginWithEmail;
--- SoObjects/SOGo/SOGoDomainDefaults.m	old
+++ SoObjects/SOGo/SOGoDomainDefaults.m	new
@@ -124,6 +124,11 @@
   return [self stringForKey: @"SOGoIMAPAclStyle"];
 }
 
+- (NSString *) imapAclGroupIdPrefix
+{
+  return [self stringForKey: @"NGImap4ConnectionGroupIdPrefix"];
+}
+
 - (NSString *) imapFolderSeparator
 {
   return [self stringForKey: @"NGImap4ConnectionStringSeparator"];
