[python-ldap] Error trying to test python-ldap install.

Michael Ströder michael at stroeder.com
Sat Aug 13 19:58:08 CEST 2011


Scott Batchelor wrote:
> I have verified that I can connect to the LDAP server and return the desired
> result via a simple ldapsearch command line.  

Ok.

> Here is the result of checking the module install.
> $ python –c "import ldap;print ldap._version_"
> 2.4.4

You problaby meant __version__. Note the doube underscores.

Note that 2.4.4 is from CVS HEAD and this code was not officially released
yet. Expect changes... Why are you using CVS HEAD?

> Upon trying to run the following script:  **Note dummy values have replaced
> real values to protect the innocent.

Hmm, it's right to replace real values. But I suspect that therein lies the
problem.

> l = ldap.initialize('ldap//localhost:389')
> l.simple_bind_s()
> l.search_s('base',ldap.SCOPE_SUBTREE,'filter')
> 
> I receive this error:
> [..]
> ldap.LDAPError: (2, 'No such file or directory')

I'd set trace_level=2 to observe which argument values are really passed to
python-ldap.

See http://www.python-ldap.org/doc/html/ldap.html#ldapobject-classes

If that does not provide any clue it might be worth looking at OpenLDAP logs.
See Demo/initialize.py how to set option ldap.OPT_DEBUG_LEVEL.

Note that the OpenLDAP libs use parameter defaults from ldap.conf(5) unless
you explicitly turn that off by adding os.environ['LDAPNOINIT']='1' to your code.

Ciao, Michael.


More information about the python-ldap mailing list