sample code online

Michael Engelhart mengelhart at katahdinsoftware.com
Sun Nov 3 19:04:13 CET 2002


Thanks for the changes and comments.  I'll edit those tonight and 
upload.

As for ldap.async.List are you suggesting that we'll have some more 
user friendly wrappers for python-ldap?  Is that something that people 
are working on?  I think that would be a great thing if we could get an 
easier to use wrapper around the low-level calls.

Cheers
Mike
On Sunday, November 3, 2002, at 12:35  PM, Michael Ströder wrote:

> Michael Engelhart wrote:
>> I just put a very simple set of python-ldap sample code that shows 
>> searching a directory, binding to a directory, and deleting entries:
>> http://homepage.mac.com/mengelhart/python-ldap-samples.html
>
> Thanks for contributing that. I've added a link to this page to 
> http://python-ldap.sourceforge.net/docs.shtml .
>
> Some comments:
>
> As default an LDAPv2 connection is made by the OpenLDAP client libs. 
> Therefore you have to explicitly set the attribute protocol_version to 
> use LDAPv3. Personally I prefer to use:
>
>   l.set_option(ldap.OPT_PROTOCOL_VERSION,ldap.VERSION3)
>
> This is especially true in the search example:
>
> -------------------- snip ------------------
> ## first you must open a connection to the server
> try:
> 	l = ldap.open("127.0.0.1")
> 	## searching doesn't require a bind 	
> except ldap.LDAPError, e:
> 	print e
> 	# handle error however you like
> -------------------- snip ------------------
>
> Here you state that a BindRequest is not needed before the 
> SearchRequest. This is only true for LDAPv3! Most times an LDAPv2 
> server will give you back ldap.PROTOCOL_ERROR (or behave odd ;-).
>
> It should read:
>
> -------------------- snip ------------------
> ## first you must open a connection to the server
> try:
> 	l = ldap.open("127.0.0.1")
>         l.protocol_version = ldap.VERSION3
> 	## with LDAPv3 searching doesn't require a bind
> except ldap.LDAPError, e:
> 	print e
> 	# handle error however you like
> -------------------- snip ------------------
>
> Unfortunately if LDAPv3 is not supported you will get an error at the 
> point where you send the first LDAPRequest (the SearchRequest in your 
> example).
>
> Now one might wonder how to properly "negotiate" the LDAP protocol 
> version. Well, check out how it's done 
> ldap.ldapobject.SmartLDAPObject. This is not ready for prime time yet 
> but should give you some inspiration. Please test!
>
> Your async search example is a good starting point to lead over to 
> deploying class ldap.async.List. ;-)
>
> Well, everybody is encouraged to dig into Demo/ anyway.
>
> Ciao, Michael.
>



More information about the python-crypto mailing list