By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,272 Members | 1,733 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,272 IT Pros & Developers. It's quick & easy.

ldapsearch example in python-ldap?

P: n/a
Hi there,

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=co m"

How can I do this with python-ldap?

Regards,
Nico
Nov 23 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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=co m"

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=co m",
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/d...p-objects.html

Ciao, Michael.
Nov 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.