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.
This commit is contained in:
Michael Gregson 2008-12-20 18:49:02 -05:00
parent 868b4b681b
commit e334437d6d
1 changed files with 12 additions and 5 deletions

View File

@ -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