Hey,
I'm trying to use python-ldap to do something that works with the
ldapsearch command line tool. I've posted code samples, can someone
point out why the python-ldap fails? What is different about what
python-ldap is doing. It seems that it forgets that it just _did_ bind
successfully...
thanks in advance,

_James
ja...@cs.mcgill.ca


# from a command line you can successfully run:
# $ # ldapsearch -x -b "<your dc...>" -D "place\<shortname>" -h <host>
-p 389 -W
"(&(objectcategory=person)(objectclass=user)(samaccountname=<shortname>))"
# <enter password>
# <see results>

# however this doesn't work:
import ldap
import sys
import getpass

l = ldap.initialize('ldap://<host>:389')

try:
        #l.simple_bind_s('first.l...@example.com', getpass.getpass())
l.simple_bind_s('<place>\<shortname>', getpass.getpass())                       
# Works

except Exception, e:
        print e
        print 'Bind Failed'
        sys.exit(1)

try:
        r = l.search_s('dc=<dc...>', ldap.SCOPE_SUBTREE,
'(&(objectcategory=person)(objectclass=user)(samaccountname=<shortname>))', 
['*'])

except Exception, e:
        print e
        # this prints:
        # {'info': '00000000: LdapErr: DSID-0C090627, comment: In order to
perform this operation a successful bind must be completed on the
connection., data 0, vece', 'desc': 'Operations error'}
        print 'Search Died'
        sys.exit(1)

for x in r:
        print x




------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Python-LDAP-dev mailing list
Python-LDAP-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev

Reply via email to