|
From: Hans A. <Han...@Ph...> - 2002-03-14 12:13:03
|
Hi all,
Ooops, the sources I sent last time did not even compile. Sorry. I
should really try if things complile after adding comments ;-)
I think I am getting closer to something usable. SASL binds should work
now for different mechanisms. A short demo:
----------------------------8<-------------------------------
import ldap
# For documentation, see Module/LDAPObject.c
def callback(id, challenge, prompt, defresult):
print "id=%d, challenge=%s, prompt=%s, defresult=%s" % \
(id, challenge, prompt, defresult)
if id == 16386: # XXX these constants are defined in sasl.h
return "aschauer"
if id == 16388:
return "secret" # this is the sasl password in sasldb
return ""
l = ldap.initialize("ldap://localhost/")
l.sasl_bind_s("","DIGEST-MD5", callback)
res = l.search_s("dc=theorie,dc=physik,dc=uni-muenchen,dc=de",
ldap.SCOPE_SUBTREE,
"objectclass=*")
print res
l.unbind()
----------------------------8<-------------------------------
I do not like the callback interface. Should use something more clever
(perhaps an instance of a sasl object should be passed, which handles
the callback internally, and also defines the mechanism string).
Hans
--
Han...@Ph...
|