connect_sasl no longer causes entire program to die on error condition.
authorMichael Gregson <mgregson@csclub.uwaterloo.ca>
Sat, 20 Dec 2008 23:49:02 +0000 (18:49 -0500)
committerMichael Gregson <mgregson@csclub.uwaterloo.ca>
Sat, 20 Dec 2008 23:49:02 +0000 (18:49 -0500)
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

index 3cd58b6..6e5eb5a 100644 (file)
@@ -10,12 +10,19 @@ from subprocess import Popen, PIPE
 
 def connect_sasl(uri, mech, realm, password):
 
-    # open the connection
-    ld = ldap.initialize(uri)
-
-    # authenticate
-    sasl = Sasl(mech, realm, password)
-    ld.sasl_interactive_bind_s('', sasl)
+    try:
+        # open the connection
+        ld = ldap.initialize(uri)
+        
+        # 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