From ad5c4ebef590371352b4349443a7661fd25301ac Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sun, 1 Dec 2013 22:20:41 +0100 Subject: Not all LDAPError's have an 'info' key. --- lib/openldap | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/openldap b/lib/openldap index 983299a..020017c 100644 --- a/lib/openldap +++ b/lib/openldap @@ -336,7 +336,14 @@ def main(): except subprocess.CalledProcessError, e: module.fail_json(rv=e.returncode, msg=e.output.rstrip()) except ldap.LDAPError, e: - module.fail_json(msg=e.args[0]['info']) + e = e.args[0] + if 'info' in e.keys(): + msg = e['info'] + elif 'desc' in e.keys(): + msg = e['desc'] + else: + msg = str(e) + module.fail_json(msg=msg) except KeyError, e: module.fail_json(msg=str(e)) -- cgit v1.2.3