catch a keyerror
This commit is contained in:
parent
f92018b649
commit
1bc5b9dfb1
@ -34,12 +34,12 @@ class LDAP(object):
|
|||||||
self.conn.start_tls_s()
|
self.conn.start_tls_s()
|
||||||
|
|
||||||
def _get_email(self, server, username):
|
def _get_email(self, server, username):
|
||||||
|
try:
|
||||||
results = self.conn.search_s(server['LDAP_SEARCH_BASE'],
|
results = self.conn.search_s(server['LDAP_SEARCH_BASE'],
|
||||||
ldap.SCOPE_SUBTREE, 'uid={0}'
|
ldap.SCOPE_SUBTREE, 'uid={0}'
|
||||||
.format(username),
|
.format(username),
|
||||||
[server['EMAIL_SEARCH_FIELD']])
|
[server['EMAIL_SEARCH_FIELD']])
|
||||||
|
|
||||||
try:
|
|
||||||
email = results[0][1][server['EMAIL_SEARCH_FIELD']][0]
|
email = results[0][1][server['EMAIL_SEARCH_FIELD']][0]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
email = None
|
email = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user