problem with filter

Michael Ströder michael at stroeder.com
Sun Aug 11 15:51:43 CEST 2002


Tjabo Kloppenburg wrote:
> 
> I'm writing a program in python wir python-ldap2.0.0.-pre04 (linux).
> 
> I can do all sorts of things, like searching:
>   L = myldap.search_s( base, ldap.SCOPE_SUBTREE, "uid=ma*" )

"uid=ma*" is not a valid search filter. Use "(uid=ma*)" instead. 
See RFC2254 as stated in the docs.

> let's say I have found twenty results, and I let the user chose one of the DNs.
> Now I want to retrieve the data of the object of a given dn.

If you did not specify args attrlist and attrsonly the entry data 
is already in the search result above.

> The problem is how to tell
> ldap.search_s to get the data of a dn like "uid=freak,ou=staff,o=company".
> 
>   L = myldap.search_s( base, ldap.SCOPE_SUBTREE, dn )
> gives an empty list.

This call is wrong. Should be:

     L = myldap.search_s( dn, ldap.SCOPE_BASE, "(objectClass=*)" )

Read the docs for search().

Ciao, Michael.






More information about the python-ldap mailing list