From: Rodney Ewing Date: Tue, 9 Jul 2013 20:44:26 +0000 (-0700) Subject: catch a keyerror X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1bc5b9dfb12fc521d805115545db6a080b8f392e;p=mediagoblin.git catch a keyerror --- 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