--- LDAP.pm.old 2008-12-18 17:14:36.000000000 +0000
+++ LDAP.pm     2009-01-09 17:07:31.000000000 +0000
@@ -471,14 +471,18 @@
     # Intermediate multidomain support:
     # We accept domain encoded in CN...
     if( $p eq 'sf' && index( $uid, '@' ) < 0 ) {
-      # We have to create shared folders
-      # with names shared.<fldrname>@<domain>
-      my @dcs = split(/,/,$object->dn());
-      my @dn;
-      while( pop( @dcs ) =~ /dc=(.*)/ ) {
-       push(@dn, $1);
+      if($object->exists('mail')) {
+        $uid = $object->get_value('mail');
+      } else {
+        # We have to create shared folders
+        # with names shared.<fldrname>@<domain>
+        my @dcs = split(/,/,$object->dn());
+        my @dn;
+        while( pop( @dcs ) =~ /dc=(.*)/ ) {
+       push(@dn, $1);
+        }
+        if( $#dn > 0 ) { $uid .= '@'.join('.',reverse(@dn)); }
       }
-      if( $#dn > 0 ) { $uid .= '@'.join('.',reverse(@dn)); }
     }
     if (!$uid) {
         Kolab::log('L', "Kolab::LDAP::createObject() called with null id attribute `$objuidfield', returning", KOLAB_DEBUG);
