Branch 'pykolab-0.5' - pykolab/auth pykolab/imap

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Thu Jan 16 13:53:43 CET 2014


 pykolab/auth/ldap/__init__.py |   20 ++++++++++++++++++--
 pykolab/imap/__init__.py      |   14 +++++++++++++-
 2 files changed, 31 insertions(+), 3 deletions(-)

New commits:
commit af9510ce941ee013858ebb44b62fa97dcd7819e7
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Thu Jan 16 13:53:15 2014 +0100

    Make sure addresses are compared in a case-insensitive manner, and that the uri to connect to is indeed set

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)
 




More information about the commits mailing list