From 1bc5b9dfb12fc521d805115545db6a080b8f392e Mon Sep 17 00:00:00 2001 From: Rodney Ewing Date: Tue, 9 Jul 2013 13:44:26 -0700 Subject: [PATCH] catch a keyerror --- mediagoblin/plugins/ldap/tools.py | 10 +++++----- 1 file 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 -- 2.25.1