[Zope] Strange error/traceback

Phil Harris phil.harris@zope.co.uk
Wed, 28 Feb 2001 09:40:41 -0000


Chris,

It's slightly more insidious than that.

The thing it was complaining about was the '' (empty string) on the line
where the error occurred.

Strange thing is it only complains when run in Zope not from straight
Python.

Seems as if Zope is doing something with empty strings (I've got no proof of
that thoug as they look/feel the same when printed/debugged etc).

This isn't the first time I've seen this though, it's happened various times
in various ExternalMethods (last time was a call into PyXML).

The LDAP_SCOPETREE is an integer type btw.

Any way, problem solved by doing this:

res=l.search_s('o=CM',ldap.SCOPE_SUBTREE,arg_cn)
if len(res) == 0:
    res=l.search_s('o=CF',ldap.SCOPE_SUBTREE,arg_cn)
if len(res) == 0:
    raise 'Invalid credentials'

But I'm lucky in that our LDAP server has only 2 main trees, things would
have been interesting if it had more ;)

Lucky thing is that most users are in the CM tree, so this actually speeded
things up quite dramatically.

Anyway, thanks for trying to help.

See ya

Phil
phil.harris@zweb.co.uk


----- Original Message -----
From: "Chris Withers" <chrisw@nipltd.com>
To: "Phil Harris" <phil.harris@zope.co.uk>
Cc: <zope@zope.org>
Sent: Tuesday, February 27, 2001 7:03 PM
Subject: Re: [Zope] Strange error/traceback


> >     l=ldap.open('medico.uwcm.ac.uk')
> >     cn='cn='+cn
>
> can you stick a print ldap.SCOP_SUBTREE in here?
>
> >     l.search_s('',ldap.SCOPE_SUBTREE,cn) # this is where it fails
> >     res=l.result()
> >     auth=[res[1][0][0],pwd]
> >     l.simple_bind_s(auth[0],auth[1])
> >     l.unbind_s()
> >     return 1
>
> > > > argument 1: expected string without null bytes, string found
>
> This sounds like argument 1 contains something like 'sample\000' and
> search_s doesn't like it. I wonder if there's a null terminated string
> coming back from a C function somewhere?
>
> *stab*, nope, it's still dark in here ;-)
>
> Chris