ldapsearch example in python-ldap?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nico Grubert

    #1

    ldapsearch example in python-ldap?

    Hi there,

    on a linux machine I am running this ldapsearch from the command line:

    ldapsearch -x -h myldaphost.mydo main.com \
    -D "CN=ldapuser,CN =Users,DC=mydom ain,DC=com" -w "secret" \
    -b "CN=ANYCOMPUTER ,CN=Computers,D C=mydomain,DC=c om"

    How can I do this with python-ldap?

    Regards,
    Nico
  • Michael Ströder

    #2
    Re: ldapsearch example in python-ldap?

    Nico Grubert wrote:
    >
    on a linux machine I am running this ldapsearch from the command line:
    >
    ldapsearch -x -h myldaphost.mydo main.com \
    -D "CN=ldapuser,CN =Users,DC=mydom ain,DC=com" -w "secret" \
    -b "CN=ANYCOMPUTER ,CN=Computers,D C=mydomain,DC=c om"
    >
    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.initiali ze("ldap://myldaphost.mydo main.com")
    l.simple_bind_s ("CN=ldapuser,C N=Users,DC=mydo main,DC=com","s ecret")
    r = l.search_s(
    "CN=ANYCOMPUTER ,CN=Computers,D C=mydomain,DC=c om",
    ldap.SCOPE_SUBT REE, # this is the default of ldapsearch
    "(objectClass=* )"
    )

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



    Ciao, Michael.

    Comment

    Working...