[python3-ldap] Search exception

python3ldap python3ldap at gmail.com
Tue Oct 1 15:21:44 CEST 2013


Hello Cory,
thanks for testing python3-ldap. I've release a minor update (0.6.2)
that should fix the problem. Let me know if now it works.

Thanks,
Giovanni

Have fun,
gc


2013/9/30 Cory Lutton <cory.lutton at gmail.com>:
> Hello,
>
> I have loaded up version 0.6.1 to test and am getting the output below on a
> search.
> I am testing against active directory from a windows pc with python 3.2.5.
>
> Here is my test script and the output:
> ################################################################################
> from ldap3 import Server, Connection, STRATEGY_SYNC, AUTH_SIMPLE
> from ldap3 import SEARCH_SCOPE_WHOLE_SUBTREE, SEARCH_DEREFERENCE_ALWAYS
> import pprint
>
> LDAP_HOST = 'myhostname'
> LDAP_USER = 'myuser'
> LDAP_PASS = 'mypassword'
>
> s = Server(LDAP_HOST, port = 389)
> c = Connection(s, autoBind = False, clientStrategy = STRATEGY_SYNC,
>         user=LDAP_USER, password=LDAP_PASS, authentication=AUTH_SIMPLE)
> c.open()
> print('Connection info:')
> print(c)
>
> c.bind()
> print('Bind result:')
> pprint.PrettyPrinter(indent=4).pprint(c.result)
> #print(s.info)
> result = c.search('dc=MYDOMAIN,dc=COM',
>         '(&(objectCategory=person)(sAMAccountName=myuser))',
>         SEARCH_SCOPE_WHOLE_SUBTREE,
>         SEARCH_DEREFERENCE_ALWAYS,
>         attributes=['description', 'displayName'])
>
> print('Search result:')
> pprint.PrettyPrinter(indent=4).pprint(c.result)
>
> print('Search response:')
> pprint.PrettyPrinter(indent=4).pprint(c.response)
> c.unbind()
> ################################################################################
> Connection info:
> ldap://myhostname:389 - cleartext - user: myuser - version 3 - unbound -
> open - listening - SyncWaitStrategy
> Bind result:
> {   'description': 'success',
>     'dn': '',
>     'message': '',
>     'referrals': None,
>     'result': 0,
>     'saslCreds': 'None',
>     'type': 'bindResponse'}
> Traceback (most recent call last):
>   File "\programs\python\python3_ldap_test.py", line 24, in <module>
>     attributes=['description', 'displayName'])
>   File "C:\programs\python\ldap3\connection.py", line 190, in search
>     response = self.postSendSearch(self.send('searchRequest', request,
> controls))
>   File "C:\programs\python\ldap3\strategy\syncWait.py", line 113, in
> postSendSearch
>     responses = self.getResponse(messageId)
>   File "C:\programs\python\ldap3\strategy\baseStrategy.py", line 164, in
> getResponse
>     responses = self._getResponse(messageId)
>   File "C:\programs\python\ldap3\strategy\syncWait.py", line 137, in
> _getResponse
>     dictResponse = BaseStrategy.decodeResponse(ldapResp)
>   File "C:\programs\python\ldap3\strategy\baseStrategy.py", line 217, in
> decodeResponse
>     result = searchResultReferenceResponseToDict(component)
>   File "C:\programs\python\ldap3\operation\search.py", line 440, in
> searchResultReferenceResponseToDict
>     'uri': searchRefsToList(response['uri'])
>   File
> "C:\Python32\lib\site-packages\pyasn1-0.1.7-py3.2.egg\pyasn1\type\base.py",
> line 240, in __getitem__
>     def __getitem__(self, idx): return self.getComponentByPosition(idx)
>   File
> "C:\Python32\lib\site-packages\pyasn1-0.1.7-py3.2.egg\pyasn1\type\univ.py",
> line 658, in getComponentByPosition
>     def getComponentByPosition(self, idx): return self._componentValues[idx]
> TypeError: list indices must be integers, not str
> shell returned 1
> Hit any key to close this window...
> ################################################################################
>
> According to wireshark the search is sent and the server replies with the
> answer and also with several SeachResRef entries.
>
> Any ideas?  Anything I can test to help?
>
> Thanks
>
> Cory L
>
> _______________________________________________
> python3-ldap mailing list
> python3-ldap at python.org
> https://mail.python.org/mailman/listinfo/python3-ldap
>


More information about the python3-ldap mailing list