I-D: The Java LDAP Application Program Interface

Federico Di Gregorio fog at mixadlive.com
Wed Feb 7 01:00:34 CET 2001


i still doesn't have looked at the java api, but converting your examples
to use my python classes is just a question of changing method names.
ok, i'll look into the java api and see if i can convert my classes to
respect the api.

ciao,
federico

Scavenging the mail folder uncovered David Leonard's letter:
> On Tue, 6 Feb 2001, Michael Ströder typed thusly:
> 
> > For those of you who are interested in designing/implementing a new
> > class API for python-ldap 2.0 the new Internet Draft
> >
> >   "The Java LDAP Application Program Interface"
> >
> > http://www.ietf.org/internet-drafts/draft-ietf-ldapext-ldap-java-api-13.txt
> >
> > might be interesting. It looks more suitable for Python than going
> > with the C-oriented LDAPEXT-API. Anyone interested in implementing
> > that?
> 
> well it looks nice. has anyone got any favourite bits?
> i like the decent methods on LDAPConnection.
> 
> I think that if we take the java api, and convert all the Javaisms
> to Pythonisms we could even submit "our own" RFC draft. :)
> 
> A lot in that java api is 'over the top' in terms of object-orientedness.
> Here are some:
> 	* do we really need a LDAPDN class? Isn't python's string enough?
> 	  (same with LDAPUrl - could be done in the urllib style)
> 	* AttributeSet is just a list
> 	* can we ignore/hide LDAPExtendedOperation/Response/Listener?
> 
> the java api looks overly complex. after whittling it back a bit, i think
> a nice pythonesqe api could be developed.
> 
> Here's some of the examples converted from Java to API
> 
>     #-- Example 9.1
>     import LDAP
>     ld = LDAP.Connection()
>     try:
> 	ld.connect("localhost", 389)
> 	ld.bind("", "")
> 	MY_FILTER = "sn=Jensen"
> 	MY_SEARCHBASE = "o=Ace Industry, c=US"
> 	cons = ld.getSearchConstraints()
> 	cons.setBatchSize(1)
> 	res = ld.search(MY_SEARCHBASE, ld.SCOPE_ONE, MY_FILTER, None, 0, cons)
> 	for findEntry in res:
> 		print findEntry.getDN()
> 		findAttrs = findEntry.getAttributeSet()
> 		enumAttrs = findAttrs.getAttributes()
> 		print "Attributes:"
> 		for anAttr in enumAttrs:
> 			print `anAttr.getName()`
> 			for aVal in anAttr.getStringValues()
> 				print `aVal`
>     except LDAP.Exception:
> 	print "Error!"
>     if ld.isConnected():
> 	ld.disconnect()
> 
> 
>     #-- example 9.2
>     import LDAP
> 
>     ld = LDAP.Connection()
>     try:
> 	MY_HOST = "localhost"
> 	MY_PORT = 389
> 	ld.connect(MY_HOST, MY_PORT)
> 
> 	MY_NAME = "cn=Barbara Jensen,o=Ace Industry,c=US"
> 	MY_PASSWORD = "MysteryLady"
> 	ld.bind(MY_NAME, MY_PASSWORD)
> 
> 	attrEmail = LDAP.Attribute("mail", "babs at ace.com")
> 	mod = LDAP.Modification(LDAP.REPLACE, attrEmail)
> 	ld.modify(MY_NAME, mod)
> 	print "Entry modified"
>     except LDAP.Exception:
> 	print "Error!"
>     if ld.isConnected():
> 	ld.disconnect()
> 
> Feel free to convert some more to see if you like the feel of it, or
> if it reminds you of a way that its done in another python builtin/library.
> 
> d
> -- 
> David Leonard                           David.Leonard at dstc.edu.au
> CRC For Distributed Systems Technology  Room:78-632  Ph:+61 7 336 58358
> The University of Queensland            http://www.dstc.edu.au/
> QLD 4072  AUSTRALIA                     B73CD65FBEF4C089B79A8EBADF1A932F13EA0FC8
> 
> 
> 


More information about the python-ldap mailing list