how to write filter argumnt for search function of LDAPObject class
Michael Ströder
michael at stroeder.com
Mon Mar 10 09:10:52 CET 2008
Yang Cheng Fu wrote:
>
> I am trying to access windows Active directory by using python-ldap, but
> I do not know how to write filter argument for search function.
From http://python-ldap.sourceforge.net/doc/python-ldap/ldap-objects.html:
--------------------------- snip ---------------------------
The filterstr argument is a string representation of the filter to apply in
the search.
See Also:
RFC 4515, Lightweight Directory Access Protocol (LDAP): String
Representation of Search Filters.
--------------------------- snip ---------------------------
> search(base, scope [,filterstr='(objectClass=*)' [, attrlist=None [,
> attrsonly=0]]]).
>
> For example: A filter sting which based on RFC4515
> (http://www.faqs.org/rfcs/rfc4515.html) is
> "(&(objectclass=organizationalUnit)(c=*))".
Yupp. That's exactly the string you have to pass to method search() and its
derivates as argument filterstr.
> From the docs of
> python-ldap, the forms of the argument, ('cn=fred*') and
> ('objectClass=*') can be found.
Ouch! The example filterstr values on
http://python-ldap.sourceforge.net/doc/python-ldap/ldap-example.html are
simply typos. Sorry for that.
Ciao, Michael.
More information about the python-ldap
mailing list