summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-04-17 09:49:25 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-04-17 09:49:25 +0100
commitc62189144721d0c8aa7e8a37f75eaa45fcb0735f (patch)
tree5553556c12c205999ee6f3e26d21c769e14ea99f
parent38a66012ac40ba0d984609b9eb9522f10f768daf (diff)
downloadpykolab-c62189144721d0c8aa7e8a37f75eaa45fcb0735f.tar.gz
try/except getting a user's attribute (#706)
-rw-r--r--pykolab/auth/ldap/__init__.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 5ed2c46..f8d4cdd 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -141,7 +141,7 @@ class LDAP(object):
if domain == None:
section = 'ldap'
- key = 'uri'
+ key = 'ldap_uri'
if conf.has_option(domain, 'uri'):
log.warning(_("Deprecation: Setting 'uri' for LDAP in section %s needs to be updated to 'ldap_uri'") % (domain))
@@ -899,12 +899,16 @@ class LDAP(object):
[ 'dn', attribute ]
)
- (
- _result_type,
- _result_data,
- _result_msgid,
- _result_controls
- ) = self.ldap.result3(_search)
+ try:
+ (
+ _result_type,
+ _result_data,
+ _result_msgid,
+ _result_controls
+ ) = self.ldap.result3(_search)
+ except ldap.NO_SUCH_OBJECT, e:
+ log.error(_("No such object %r in Auth::LDAP::_get_user_attribute") % (user['dn']))
+ return None
if len(_result_data) >= 1:
(user_dn, user_attrs) = _result_data[0]