From e334437d6d14a765aa1999a924fca4a72ed09f6a Mon Sep 17 00:00:00 2001 From: Michael Gregson Date: Sat, 20 Dec 2008 18:49:02 -0500 Subject: [PATCH] connect_sasl no longer causes entire program to die on error condition. However, accessing LDAP beyond this point is probably a really bad idea as we certainly do not do anything sane to handle the error. --- ceo/ldapi.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ceo/ldapi.py b/ceo/ldapi.py index 3cd58b633..6e5eb5acd 100644 --- a/ceo/ldapi.py +++ b/ceo/ldapi.py @@ -10,12 +10,19 @@ from subprocess import Popen, PIPE def connect_sasl(uri, mech, realm, password): - # open the connection - ld = ldap.initialize(uri) + try: + # open the connection + ld = ldap.initialize(uri) + + # authenticate + sasl = Sasl(mech, realm, password) + ld.sasl_interactive_bind_s('', sasl) - # authenticate - sasl = Sasl(mech, realm, password) - ld.sasl_interactive_bind_s('', sasl) + except ldap.LOCAL_ERROR, e: + raise e + + except: + print "Shit, something went wrong!" return ld