simple ldap query
david.leonard at csee.uq.edu.au
Wed Jul 26 01:15:54 CEST 2000
On Tue, 25 Jul 2000, Leichtman, David J typed thusly:
> I was wondering if I could enlist your help with a rather simple thing that
> I haven't been able to figure out through the python - LDAP documentation.
> I've been trying to put together a very simple auth module using our LDAP
> server at University of Oklahoma. My problem is that I don't know exactly
> how to format the dn, but that's not really my problem. The real problem is
> that I can't figure out how to get good error info. I can't really figure
> out what the right way to call the bind is in order to autheticate with it.
> I seem to always get an exception, but it never matches any of the ones that
> are listed in the documentation, and I don't know how to just list all
> raised exceptions.
what exception exactly is raised?
> Maybe you can help, or just point out a grossly negligent error on my part.
since 1.9, all exceptions raised are subclasses of the base exception
_ldap.LDAPError (except for PARAM_ERROR, NO_SUCH_OBJECT and NO_SUCH_ATTRIBUTE
which are (incorrectly) mapped to python exceptions ValueError, NameError &
This is tersely refered to in the documentation (look for LDAPError). But here
is some python code to show all the errors.
import types, _ldap
for s in dir(_ldap):
o = getattr(_ldap, s)
if type(o) is types.ClassType and issubclass(o, _ldap.LDAPError):
print s, o
When an exception object/value/traceback triple is raised from an LDAP
error, the value is a dictionary with three string keys: 'desc', 'matched'
(optional) and 'info' (also optional).
if you have openldap installed, the manual page `ldap_perror(3)' describes
each error type in a bit more detail.
David Leonard David.Leonard at csee.uq.edu.au
Dept of Comp. Sci. and Elec. Engg _ Room:78-640 Ph:+61 7 336 51187
The University of Queensland |+| http://www.csee.uq.edu.au/~leonard/
QLD 4072 AUSTRALIA ~` '~ E2A24DC6446E5779D7AFC41AA04E6401
Curses! - Mojo Jojo
More information about the python-ldap