From: David L. <dav...@cs...> - 2000-07-25 23:16:18
|
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 & AttributeError). 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 Dav...@cs... 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 |
From: David L. <dav...@cs...> - 2000-07-26 00:16:17
|
(sorry about the blast of messages this morning) On Wed, 26 Jul 2000, David Leonard typed thusly: > 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 & > AttributeError). this worries me. should the PARAM_ERROR, NO_SUCH_OBJECT and NO_SUCH_ATTRIBUTE errors not be mapped into python exceptions in the next release? won't this break existing code?? d -- David Leonard Dav...@cs... 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 |
From: Michael <mi...@st...> - 2000-07-26 07:48:37
|
David Leonard wrote: > > this worries me. should the PARAM_ERROR, NO_SUCH_OBJECT and > NO_SUCH_ATTRIBUTE > errors not be mapped into python exceptions in the next release? won't this > break existing code?? I'm making heavy use of e.g. catching ldap.NO_SUCH_OBJECT. But all exceptions should be derived from ldap.LDAPError or whatever it's called. Ciao, Michael. |
From: David L. <dav...@cs...> - 2000-07-26 10:12:51
|
On Wed, 26 Jul 2000, Michael Ströder typed thusly: > David Leonard wrote: > > this worries me. should the PARAM_ERROR, NO_SUCH_OBJECT and > > NO_SUCH_ATTRIBUTE > > errors not be mapped into python exceptions in the next release? won't this > > break existing code?? > > I'm making heavy use of e.g. catching ldap.NO_SUCH_OBJECT. ok your code won't break; but those people who noticed that ValueError, AttributeError etc are being thrown and instead use those names will be bitten. > But all exceptions should be derived from ldap.LDAPError or whatever > it's called. thats what i reckon... and i'll change it so, if nobody seriously objects..? d -- David Leonard Dav...@cs... 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 |
From: David L. <dav...@cs...> - 2000-07-26 10:22:03
|
On Wed, 26 Jul 2000, David Leonard typed thusly: > thats what i reckon... and i'll change it so, if nobody seriously objects..? ignore my insane ravings. all exceptions are derived from a base exception class and seem to have been for a couple of versions. i have deleted misleading comments -- David Leonard Dav...@cs... 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 |
From: Michael <mi...@st...> - 2000-07-26 19:15:35
|
David Leonard wrote: > > On Wed, 26 Jul 2000, David Leonard typed thusly: > > > thats what i reckon... and i'll change it so, if nobody seriously > > objects..? > > ignore my insane ravings. all exceptions are derived from a base exception > class and seem to have been for a couple of versions. I'm trying to catch a ldap.error base class (using 1.9-alpha) but did not succeed. Did I do something wrong? Hmm, it would make sense to add a constant ldap.moduleversion symbol... Ciao, Michael. |
From: David L. <dav...@cs...> - 2000-07-27 01:30:11
|
On Wed, 26 Jul 2000, Michael Ströder typed thusly: > > > thats what i reckon... and i'll change it so, if nobody seriously > > > objects..? > > ignore my insane ravings. all exceptions are derived from a base exception > > class and seem to have been for a couple of versions. > > I'm trying to catch a ldap.error base class (using 1.9-alpha) but > did not succeed. Did I do something wrong? i don't know... it should work. I'm using PyErr_NewException() to create new exception classes... will try to test here > Hmm, it would make sense to add a constant ldap.moduleversion > symbol... its already there, as __version__ :) >>> import _ldap >>> _ldap.__version__ '1.9' d -- David Leonard Dav...@cs... 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 |