ldap3 icon indicating copy to clipboard operation
ldap3 copied to clipboard

pyasn1.error.PyAsn1Error: Attempted "decode" operation on ASN.1 schema object

Open myuconnect opened this issue 5 years ago • 2 comments

Hello,

I am getting following error when trying to bind the ldap connection object, following is the information.

PyAsn1 : 0.4.8 ldap3 : 2.8.1 Python: 3.9.0

Code: Python 3.9.0 (default, Dec 1 2020, 12:27:39) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux Type "help", "copyright", "credits" or "license" for more information.

from ldap3 import Server, Connection, AUTO_BIND_NO_TLS, SUBTREE, BASE, ALL_ATTRIBUTES, ALL_OPERATIONAL_ATTRIBUTES, ObjectDef, AttrDef, Reader, Entry, Attribute, OperationalAttribute, ObjectDef, AttrDef, Reader, Entry, Attribute, OperationalAttribute server = Server('ldap.server' port=389, use_ssl=False, get_info='ALL') adUser = "\", adUserPass = "<secret_pass>" connection = Connection(server,user = adUser, password = adUserPass) connection.bind() Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.9/site-packages/ldap3-2.8.1-py3.9.egg/ldap3/core/connection.py", line 600, in bind File "/usr/local/lib/python3.9/site-packages/ldap3-2.8.1-py3.9.egg/ldap3/strategy/base.py", line 328, in send File "/usr/local/lib/python3.9/site-packages/ldap3-2.8.1-py3.9.egg/ldap3/strategy/base.py", line 638, in decode_request File "/usr/local/lib/python3.9/site-packages/ldap3-2.8.1-py3.9.egg/ldap3/operation/bind.py", line 95, in bind_request_to_dict File "/usr/local/lib/python3.9/site-packages/pyasn1-0.4.8-py3.9.egg/pyasn1/type/univ.py", line 916, in str File "/usr/local/lib/python3.9/site-packages/pyasn1-0.4.8-py3.9.egg/pyasn1/type/base.py", line 236, in getattr pyasn1.error.PyAsn1Error: Attempted "decode" operation on ASN.1 schema object

Any help would be appreciated. This code works on Python 3.6

myuconnect avatar Dec 19 '20 22:12 myuconnect

Hi, can you give more information on this error? What is the actual name of the user you're trying to bind?

cannatag avatar Dec 26 '20 21:12 cannatag

Hi there - I am having a similar issue.

my backend LDAP Server is ApacheDS.

I have tried various combination of python version (3.6, 3.9) and pysan1 and ldap3.

What combination works ?

Python version

python -V
Python 3.6.8

Installed Packages

pip list
Package    Version
---------- -------
bottle     0.12.19
ldap3      2.5.1
pip        21.3.1
pyasn1     0.4.8
setuptools 39.2.0

Error Stack

[TRUNCATED]
  File "app.py", line 134, in change_password_ldap
    c.extend.standard.modify_password(user_dn, old_pass, new_pass)
  File "_REDACTED_/ldap_password_webui/ldap-passwd-webui/venv/lib64/python3.6/site-packages/ldap3/extend/__init__.py", line 81, in modify_password
    controls).send()
  File "_REDACTED_/ldap_password_webui/ldap-passwd-webui/venv/lib64/python3.6/site-packages/ldap3/extend/operation.py", line 59, in send
    self.populate_result()
  File "_REDACTED_/ldap_password_webui/ldap-passwd-webui/venv/lib64/python3.6/site-packages/ldap3/extend/standard/modifyPassword.py", line 64, in populate_result
    self.result[self.response_attribute] = str(self.decoded_response['genPasswd'])
  File "_REDACTED_/ldap_password_webui/ldap-passwd-webui/venv/lib64/python3.6/site-packages/pyasn1/type/univ.py", line 916, in __str__
    return self._value.decode(self.encoding)
  File "_REDACTED_/ldap_password_webui/ldap-passwd-webui/venv/lib64/python3.6/site-packages/pyasn1/type/base.py", line 236, in __getattr__
    raise error.PyAsn1Error('Attempted "%s" operation on ASN.1 schema object' % attr)
pyasn1.error.PyAsn1Error: Attempted "decode" operation on ASN.1 schema object

michaelschapira avatar Apr 08 '22 15:04 michaelschapira