summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2020-01-15 18:05:19 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2020-02-23 11:03:35 +0100
commit49629e963e2f34ee0d414983768a51063206b6e0 (patch)
treece53af174ac1ed15f100b314ea8a622c1e42e255
parentb587a7640f10738cb884434296a0377fe73540a9 (diff)
downloadpykolab-49629e963e2f34ee0d414983768a51063206b6e0.tar.gz
Fix moddn on shared folder entries (Bifrost TT324146)
-rw-r--r--pykolab/auth/ldap/__init__.py34
-rw-r--r--pykolab/imap/__init__.py23
2 files changed, 50 insertions, 7 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 67e9487..f76f684 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1936,7 +1936,39 @@ class LDAP(Base):
cache.get_entry(self.domain, entry)
def _change_moddn_sharedfolder(self, entry, change):
- pass
+ result_attribute = 'cn'
+
+ old_cn = explode_dn(change['previous_dn'], True)[0]
+
+ if 'kolabtargetfolder' in entry and entry['kolabtargetfolder'] is not None:
+ new_folder_path = entry['kolabtargetfolder']
+ old_folder_path = old_cn
+
+ if '@' in entry['kolabtargetfolder']:
+ old_folder_path = "%s@%s" % (
+ old_folder_path,
+ entry['kolabtargetfolder'].split('@')[1]
+ )
+
+ else:
+ result_attribute = conf.get('cyrus-sasl', 'result_attribute')
+ if result_attribute in ['mail']:
+ new_folder_path = "%s@%s" % (entry['cn'], self.domain)
+ old_folder_path = "%s@%s" % (old_cn, self.domain)
+ else:
+ new_folder_path = "%s" % (entry['cn'])
+ old_folder_path = old_cn
+
+ if not new_folder_path.startswith('shared/'):
+ new_folder_path = "shared/%s" % (new_folder_path)
+
+ if not old_folder_path.startswith('shared/'):
+ old_folder_path = "shared/%s" % (old_folder_path)
+
+ log.debug("old folder path: %r" % (old_folder_path))
+ log.debug("new folder path: %r" % (new_folder_path))
+
+ self.imap.shared_folder_rename(old_folder_path, new_folder_path)
def _change_modify_None(self, entry, change):
pass
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index b5aff55..8ea23e7 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -421,12 +421,12 @@ class IMAP(object):
self.imap.sam(self.folder_utf7(folder), identifier, acl)
except Exception as errmsg:
log.error(
- _("Could not set ACL for %s on folder %s: %r") % (
- identifier,
- folder,
- errmsg
- )
+ _("Could not set ACL for %s on folder %s: %r") % (
+ identifier,
+ folder,
+ errmsg
)
+ )
def set_metadata(self, folder, metadata_path, metadata_value, shared=True):
"""
@@ -453,7 +453,7 @@ class IMAP(object):
if folder_name.startswith("shared%s" % (self.get_separator()) * 2):
folder_name = folder_name[7:]
- log.info(_("Creating new shared folder %s") %(folder_name))
+ log.info(_("Creating new shared folder %s") % (folder_name))
self.create_folder(folder_name, server)
def shared_folder_exists(self, folder_path):
@@ -468,6 +468,17 @@ class IMAP(object):
return self.has_folder(folder_name)
+ def shared_folder_rename(self, old, new):
+ if not self.has_folder(old):
+ log.error("Shared Folder rename error: Folder %s does not exist" % (old))
+ return
+
+ if self.has_folder(new):
+ log.error("Shared Folder rename error: Folder %s already exists" % (new))
+ return
+
+ self.imap._rename(old, new)
+
def shared_folder_set_type(self, folder_path, folder_type):
folder_name = 'shared%s%s' % (self.get_separator(), folder_path)