aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodney Ewing <ewing.rj@gmail.com>2013-07-09 13:44:26 -0700
committerRodney Ewing <ewing.rj@gmail.com>2013-08-15 16:01:48 -0700
commit1bc5b9dfb12fc521d805115545db6a080b8f392e (patch)
tree3158ab84c0143bb6c85cba73a6887964fc806814
parentf92018b649c98fb6d5b6f7c067e56fb7587e4707 (diff)
downloadmediagoblin-1bc5b9dfb12fc521d805115545db6a080b8f392e.tar.lz
mediagoblin-1bc5b9dfb12fc521d805115545db6a080b8f392e.tar.xz
mediagoblin-1bc5b9dfb12fc521d805115545db6a080b8f392e.zip
catch a keyerror
-rw-r--r--mediagoblin/plugins/ldap/tools.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/mediagoblin/plugins/ldap/tools.py b/mediagoblin/plugins/ldap/tools.py
index 35a681ec..1c436792 100644
--- a/mediagoblin/plugins/ldap/tools.py
+++ b/mediagoblin/plugins/ldap/tools.py
@@ -34,12 +34,12 @@ class LDAP(object):
self.conn.start_tls_s()
def _get_email(self, server, username):
- results = self.conn.search_s(server['LDAP_SEARCH_BASE'],
- ldap.SCOPE_SUBTREE, 'uid={0}'
- .format(username),
- [server['EMAIL_SEARCH_FIELD']])
-
try:
+ results = self.conn.search_s(server['LDAP_SEARCH_BASE'],
+ ldap.SCOPE_SUBTREE, 'uid={0}'
+ .format(username),
+ [server['EMAIL_SEARCH_FIELD']])
+
email = results[0][1][server['EMAIL_SEARCH_FIELD']][0]
except KeyError:
email = None