summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2016-10-06 09:45:20 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2016-10-06 09:45:20 +0200
commite75b015fa96721968083a10d205187ffe8e335d3 (patch)
treecd7739cc827f19f1b2689036684b185aa31e2ff8 /pykolab
parentf57e5263ed37d61548e04e0ba7e591cfecf3edc6 (diff)
downloadpykolab-e75b015fa96721968083a10d205187ffe8e335d3.tar.gz
T1417: Fix so sync-mailhost-attr uses result_attribute not mail_attributes
Summary: Fixes T1417 Reviewers: #pykolab_developers, vanmeeuwen Reviewed By: #pykolab_developers, vanmeeuwen Maniphest Tasks: T1417 Differential Revision: https://git.kolab.org/D209
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/auth/__init__.py4
-rw-r--r--pykolab/auth/ldap/__init__.py15
-rw-r--r--pykolab/cli/cmd_sync_mailhost_attrs.py9
3 files changed, 17 insertions, 11 deletions
diff --git a/pykolab/auth/__init__.py b/pykolab/auth/__init__.py
index 2ffd8d3..84014ae 100644
--- a/pykolab/auth/__init__.py
+++ b/pykolab/auth/__init__.py
@@ -193,7 +193,7 @@ class Auth(pykolab.base.Base):
else:
return result
- def find_recipient(self, address, domain=None):
+ def find_recipient(self, address, domain=None, search_attrs=None):
"""
Find one or more entries corresponding to the recipient address.
"""
@@ -203,7 +203,7 @@ class Auth(pykolab.base.Base):
if not self._auth or self._auth == None:
self.connect(domain=domain)
- result = self._auth.find_recipient(address)
+ result = self._auth.find_recipient(address, search_attrs=search_attrs)
if isinstance(result, list) and len(result) == 1:
return result[0]
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 62f765a..2d79df6 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -675,7 +675,7 @@ class LDAP(pykolab.base.Base):
return _entry_dns
- def find_recipient(self, address="*", exclude_entry_id=None):
+ def find_recipient(self, address="*", exclude_entry_id=None, search_attrs=None):
"""
Given an address string or list of addresses, find one or more valid
recipients.
@@ -685,6 +685,9 @@ class LDAP(pykolab.base.Base):
Specify an additional entry_id to exclude to exclude matches against
the current entry.
+
+ In search_attrs you can specify list of search attributes. By default
+ mail_attributes are used.
"""
self._bind()
@@ -701,13 +704,13 @@ class LDAP(pykolab.base.Base):
__filter_suffix = ""
kolab_filter = self._kolab_filter()
- recipient_address_attrs = self.config_get_list("mail_attributes")
-
- result_attributes = []
- for recipient_address_attr in recipient_address_attrs:
- result_attributes.append(recipient_address_attr)
+ if search_attrs is not None:
+ recipient_address_attrs = search_attrs
+ else:
+ recipient_address_attrs = self.config_get_list("mail_attributes")
+ result_attributes = recipient_address_attrs
result_attributes.append(self.config_get('unique_attribute'))
_filter = "(|"
diff --git a/pykolab/cli/cmd_sync_mailhost_attrs.py b/pykolab/cli/cmd_sync_mailhost_attrs.py
index fe7f6b2..3f5a731 100644
--- a/pykolab/cli/cmd_sync_mailhost_attrs.py
+++ b/pykolab/cli/cmd_sync_mailhost_attrs.py
@@ -71,8 +71,11 @@ def execute(*args, **kw):
auth = Auth()
auth.connect()
- domains = auth.list_domains()
+ result_attribute = conf.get('cyrus-sasl', 'result_attribute')
+ if result_attribute is None:
+ result_attribute = 'mail'
+ domains = auth.list_domains()
folders = imap.lm()
imap_domains_not_domains = []
@@ -140,7 +143,7 @@ def execute(*args, **kw):
recipient = auth.find_folder_resource(folder)
else:
r_folder = '/'.join(folder.split('/')[1:])
- recipient = auth.find_recipient(r_folder)
+ recipient = auth.find_recipient(r_folder, search_attrs=[result_attribute])
if (isinstance(recipient, list)):
if len(recipient) > 1:
@@ -188,6 +191,6 @@ def execute(*args, **kw):
if folder.startswith('shared/'):
recipient = auth.find_folder_resource(folder)
else:
- recipient = auth.find_recipient('/'.join(folder.split('/')[1:]))
+ recipient = auth.find_recipient('/'.join(folder.split('/')[1:]), search_attrs=[result_attribute])
print folder, server, recipient