[mod_python] ldap woes

mauchi mauchi at assembleco.com
Fri Aug 11 19:29:59 EDT 2006


Hi Joshua,

> if password == "":
> > 	password = "wrong"
> 

this came out of one of the ldap examples I found with google, yeah probably not so hot

> try:
> > 	l.simple_bind_s(ldapConfig % ('%s'%username), ('%s'%password))
> 
> What's with the extra string formatting? Just use:

The extra formatting I put in there just to make sure I wasn't tripping myself up with non-strings when I was trying to debug it


> And where are the values of username and password coming from?
> 
> > except ldap.LDAPError, e:
> > 	print e

once again, the code I posted was cut some from the handler, some from
the command line test script, thus the print thing. not a complete piece
but enough to paint the picture

on the stack trace, how do I enable that and where does it get logged
with mod_python?

As a test, I wrapped the ldap code as a command line tool, something
like:

validate.py -u test -p 12345

which was called from inside the handler as a system call. Not great,
not terribly smart, but the ldap authentication did work that time

Cheers,

Mchi


On Fri, 2006-08-11 at 15:08 -0400, Joshua Ginsberg wrote:
> Well, and further thoughts....
> 
> > import ldap
> > 
> > ldapServer = '192.168.1.100'
> > ldapConfig = 'uid=%s,ou=people,dc=assembleco,dc=x'
> > 
> > l = ldap.open(ldapServer)
> > 
> > if password == "":
> > 	password = "wrong"
> 
> That is just awful -- what if somebody chooses (FSM forbid) the a
> password of "wrong"?
> 
> > try:
> > 	l.simple_bind_s(ldapConfig % ('%s'%username), ('%s'%password))
> 
> What's with the extra string formatting? Just use:
> 
> l.simple_bind_s(ldapConfig % username, password)

> 
> In this case "e" is an instance of the Exception class. It's not
> necessarily predictable how this will get rendered as a string. And
> under mod_python printing to stdout won't do anything -- you're not
> running this under CGI, are you?
> 
> > #
> > 
> > Under mod_python, it fails with the following error:
> > 
> > {'desc': 'Encoding error'}
> > 
> 
> How about giving a more complete stack trace?
> 
> -jag
> 
-- 
assemble
(o) 510.524.8255 x801
(c) 510.435.9145

text page to 5104359145 at vtext.com



More information about the Mod_python mailing list