Nico Grubert wrote:
> 
> on a linux machine I am running this ldapsearch from the command line:
> 
> ldapsearch -x -h myldaphost.mydomain.com \
>   -D "CN=ldapuser,CN=Users,DC=mydomain,DC=com" -w "secret" \
>   -b "CN=ANYCOMPUTER,CN=Computers,DC=mydomain,DC=com"
> 
> How can I do this with python-ldap?

http://python-ldap.sourceforge.net/docs.shtml contains some links to
introductions.

This command above boils down to:

l=ldap.initialize("ldap://myldaphost.mydomain.com";)
l.simple_bind_s("CN=ldapuser,CN=Users,DC=mydomain,DC=com","secret")
r = l.search_s(
  "CN=ANYCOMPUTER,CN=Computers,DC=mydomain,DC=com",
  ldap.SCOPE_SUBTREE, # this is the default of ldapsearch
  "(objectClass=*)"
)

But you really should learn more about it by diving into:

http://python-ldap.sourceforge.net/doc/python-ldap/ldap-objects.html

Ciao, Michael.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to