SASL binds (part 2)

Hans Aschauer Hans.Aschauer at Physik.uni-muenchen.de
Thu Mar 14 13:12:58 CET 2002


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

-- 
Hans.Aschauer at Physik.uni-muenchen.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff
Type: text/x-diff
Size: 6889 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20020314/eea41c76/attachment.diff>


More information about the python-ldap mailing list