summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-01-16 13:53:15 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-01-16 13:53:15 +0100
commitaf9510ce941ee013858ebb44b62fa97dcd7819e7 (patch)
tree7cf58723e0d79cfe0f3cd1b79be5c19d9f8f4b5c
parentc297111746bd1fca73a9049971a8106f3be4fa16 (diff)
downloadpykolab-af9510ce941ee013858ebb44b62fa97dcd7819e7.tar.gz
Make sure addresses are compared in a case-insensitive manner, and that the uri to connect to is indeed set
-rw-r--r--pykolab/auth/ldap/__init__.py20
-rw-r--r--pykolab/imap/__init__.py14
2 files changed, 31 insertions, 3 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 9397386..46d9e44 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1111,17 +1111,33 @@ class LDAP(pykolab.base.Base):
self.imap.connect(domain=self.domain)
- if not self.imap.user_mailbox_exists(entry[result_attribute]):
+ if not self.imap.user_mailbox_exists(entry[result_attribute].lower()):
folder = self.imap.user_mailbox_create(
entry[result_attribute],
entry[mailserver_attribute]
)
else:
- folder = "user%s%s" % (self.imap.separator,entry[result_attribute])
+ folder = "user%s%s" % (self.imap.separator,entry[result_attribute].lower())
server = self.imap.user_mailbox_server(folder)
+ log.debug(
+ _("Entry %s attribute value: %r") % (
+ mailserver_attribute,
+ entry[mailserver_attribute]
+ ),
+ level=8
+ )
+
+ log.debug(
+ _("imap.user_mailbox_server(%r) result: %r") % (
+ folder,
+ server
+ ),
+ level=8
+ )
+
if not entry[mailserver_attribute] == server:
self.set_entry_attribute(entry, mailserver_attribute, server)
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index ffba13d..1bd1f77 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -110,6 +110,7 @@ class IMAP(object):
if conf.has_section(domain) and conf.has_option(domain, 'imap_uri'):
uri = conf.get(domain, 'imap_uri')
+ scheme = None
hostname = None
port = None
@@ -127,9 +128,16 @@ class IMAP(object):
if not server == None:
hostname = server
+ hostname = hostname.lower()
+
if port == None:
port = 993
+ if scheme == None or scheme == "":
+ scheme = 'imaps'
+
+ uri = '%s://%s:%s' % (scheme, hostname, port)
+
# Get the credentials
admin_login = conf.get(backend, 'admin_login')
admin_password = conf.get(backend, 'admin_password')
@@ -200,6 +208,7 @@ class IMAP(object):
folder_path = self.folder_utf7(folder_path)
if not server == None:
+ server = server.lower()
if not self._imap.has_key(server):
self.connect(server=server)
@@ -367,8 +376,11 @@ class IMAP(object):
log.warning(_("Downcasing mailbox name %r") % (mailbox_base_name))
mailbox_base_name = mailbox_base_name.lower()
+ if not server == None:
+ server = server.lower()
+
folder_name = "user%s%s" % (self.imap.separator, mailbox_base_name)
- log.info(_("Creating new mailbox for user %s") %(mailbox_base_name))
+ log.info(_("Creating new mailbox for user %s on server %r") %(mailbox_base_name, server))
self.create_folder(folder_name, server)