PerLDAP compat

David Leonard david.leonard at
Wed Jul 26 02:10:47 CEST 2000

I was looking at OO models of X.500 directories and came acrosss Perl's
LDAP module and wondered if a compatibility library could be useful to
anyone converting their perl code to python :) :)

its not finished yet but you can see the gist of the api below.

any comments? a waste of time?

The Perl API is documented at

# python

'''PerLDAP-like interface to the Python LDAP library

class Conn:
	def __init__(self, host, port = str(_ldap.PORT), 
			bind = '', pswd = '', cert = ldap.AUTH_SIMPLE):, self.port, self.binf = host, port, bind
		self._l =, int(port))
		self._l.bind_s(bind, pswd, cert)
	def search(self, base, scope, pattern):
		'''search(base, scope, pattern) -> Entry'''
		self._context =, pattern)
		return self.nextEntry()
	def searchURL(self, url):
		'''searchURL(url) -> Entry'''
	def nextEntry(self):
		'''nextEntry() -> Entry'''
		ret = self._l.result(self._context)
		if ret[0] == _ldap.RES_SEARCH_RESULT:
			del self._context
			return None
		assert ret[0] == _ldap.RES_SEARCH_ENTRY
		return Entry(ret[1])
	def update(self, entry):
		'''update(entry) -> int'''
	def add(self, entry):
		'''add(entry) -> int'''
	def delete(self, entry):
		'''delete(entry) -> int'''
	def close(self):
		'''close() -> Entry'''
	def modifyRDN(self, rdn, dn):
		'''modifyRDN(rdn, dn) -> Entry'''
	def isURL(self, url):
		'''isURL(url) -> int'''
	def getLD(self):
		'''getLD() -> fd int'''
	def getErrorCode(self):
		'''getErrorCode() -> int'''
	def getErrorString(self):
		'''getErrorString() -> string'''
	def printError(self):
	def setRebindProc(self, func):
	def setDefaultRebindProc(self):

class Entry:
	def attrModified(self, attr):
	def isModified(self, attr):
		'''isModified(attr) -> int'''
	def remove(self, attr):
	def removeValue(self, attr, val):
		'''removeValue(attr, val)'''
	def addValue(self, attr, val):
		'''addValue(attr, val)'''
	def hasValue(self, attr, val, ignorecase = 0):
		'''hasValue(attr, val [, ignorecase]) -> int'''
	def matchValue(self, attr, ignorecase = 0):
		'''matchValue(attr [, ignorecase]) -> int'''
	def setDN(self, dn):
	def getDN(self, dn):
		'''getDN(dn) -> string'''
	def size(self, attr):
		'''size(attr) -> int'''
	def exists(self, attr):
		'''exists(attr) -> int'''
	def printLDIF(self):
	def __getitem__(self, attr):
	def __setitem__(self, attr, value):
David Leonard                           David.Leonard at
Dept of Comp. Sci. and Elec. Engg   _   Room:78-640  Ph:+61 7 336 51187
The University of Queensland       |+|
QLD 4072  AUSTRALIA               ~` '~ E2A24DC6446E5779D7AFC41AA04E6401

Curses! - Mojo Jojo

More information about the python-ldap mailing list