summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-05-19 12:52:47 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-05-19 12:52:47 +0200
commitd0ef194abe3cb3634101d488c8539c47a3616d93 (patch)
tree3ea16c50cdfd8761542d1b90adda6ad4c5f116fb
parent4f566bcd9cecfb26363cbd0f047b5c6e9a513c6f (diff)
parentfdf323657d2ccb3dcb3b77bed091707b2dfc0c23 (diff)
downloadpykolab-d0ef194abe3cb3634101d488c8539c47a3616d93.tar.gz
Merge branch 'master' of ssh://git.kolab.org/git/pykolab
-rw-r--r--pykolab/auth/ldap/__init__.py21
-rw-r--r--pykolab/plugins/recipientpolicy/__init__.py24
-rw-r--r--pykolab/utils.py3
3 files changed, 41 insertions, 7 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 0a564fa..441153a 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -566,6 +566,9 @@ class LDAP(pykolab.base.Base):
}
)
+ if primary_mail_address == None:
+ return entry_modifications
+
i = 1
_primary_mail = primary_mail_address
@@ -1182,6 +1185,9 @@ class LDAP(pykolab.base.Base):
if entry[result_attribute] == None:
return
+ if entry[result_attribute] == '':
+ return
+
cache.get_entry(self.domain, entry)
self.imap.connect(domain=self.domain)
@@ -1313,6 +1319,15 @@ class LDAP(pykolab.base.Base):
for key in entry_changes.keys():
entry[key] = entry_changes[key]
+ if not entry.has_key(result_attribute):
+ return
+
+ if entry[result_attribute] == None:
+ return
+
+ if entry[result_attribute] == '':
+ return
+
# Now look at entry_changes and old_canon_attr, and see if they're
# the same value.
if entry_changes.has_key(result_attribute):
@@ -2426,7 +2441,11 @@ class LDAP(pykolab.base.Base):
break
- except:
+ except Exception, errmsg:
+ log.error(_("An error occured using %s: %r") % (supported_control, errmsg))
+ if conf.debuglevel > 8:
+ import traceback
+ traceback.print_exc()
continue
return _results
diff --git a/pykolab/plugins/recipientpolicy/__init__.py b/pykolab/plugins/recipientpolicy/__init__.py
index 8dff05e..6ca70ef 100644
--- a/pykolab/plugins/recipientpolicy/__init__.py
+++ b/pykolab/plugins/recipientpolicy/__init__.py
@@ -77,9 +77,10 @@ class KolabRecipientpolicy(object):
return mail
except KeyError, e:
log.warning(_("Attribute substitution for 'mail' failed in Recipient Policy"))
- mail = utils.translate(user_attrs['mail'], user_attrs['preferredlanguage'])
- mail = mail.lower()
- return mail
+ if user_attrs.has_key('mail'):
+ return user_attrs['mail']
+ else:
+ return None
def set_secondary_mail(self, *args, **kw):
"""
@@ -120,7 +121,14 @@ class KolabRecipientpolicy(object):
_domains = [ kw['primary_domain'] ] + kw['secondary_domains']
for attr in [ 'givenname', 'sn', 'surname' ]:
- user_attrs[attr] = utils.translate(user_attrs[attr], user_attrs['preferredlanguage'])
+ try:
+ user_attrs[attr] = utils.translate(user_attrs[attr], user_attrs['preferredlanguage'])
+ except Exception, errmsg:
+ log.error(_("An error occurred in composing the secondary mail attribute for entry %r") % (user_attrs['id']))
+ if conf.debuglevel > 8:
+ import traceback
+ traceback.print_exc()
+ return []
for number in alternative_mail_routines.keys():
for routine in alternative_mail_routines[number].keys():
@@ -130,8 +138,12 @@ class KolabRecipientpolicy(object):
log.debug(_("Appending additional mail address: %s") % (retval), level=8)
alternative_mail.append(retval)
- except KeyError, e:
- log.warning(_("Attribute substitution for 'alternative_mail' failed in Recipient Policy"))
+ except Exception, errmsg:
+ log.error(_("Policy for secondary email address failed: %r") % (errmsg))
+ if conf.debuglevel > 8:
+ import traceback
+ traceback.print_exc()
+ return []
for _domain in kw['secondary_domains']:
user_attrs['domain'] = _domain
diff --git a/pykolab/utils.py b/pykolab/utils.py
index b0de166..5cba8f9 100644
--- a/pykolab/utils.py
+++ b/pykolab/utils.py
@@ -321,6 +321,9 @@ def normalize(_object):
result['surname'] = result['sn'].replace(' ', '')
if result.has_key('mail'):
+ if isinstance(result['mail'], list):
+ result['mail'] = result['mail'][0]
+
if len(result['mail']) > 0:
if len(result['mail'].split('@')) > 1:
result['domain'] = result['mail'].split('@')[1]