More informative error message when LDAP messes up

This commit is contained in:
Martin Pépin 2020-06-20 17:22:50 +02:00
parent 744f12dccf
commit 1fc2a04040
No known key found for this signature in database
GPG key ID: E7520278B1774448

View file

@ -36,7 +36,10 @@ def fetch_cas_account(cas_login):
if not res:
return None
if len(res) != 1:
raise RuntimeError("LDAP returned too many results: {}".format(res))
(res,) = res
assert _extract_ldap_info(res, "uid") == cas_login
return {
"cn": _extract_ldap_info(res, "cn"),