Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: ModifyOp in the Delta module cannot serialize from LDAP #223

Open
xdesai opened this issue Apr 16, 2021 · 0 comments
Open

Bug: ModifyOp in the Delta module cannot serialize from LDAP #223

xdesai opened this issue Apr 16, 2021 · 0 comments

Comments

@xdesai
Copy link
Contributor

xdesai commented Apr 16, 2021

Hey ldaptor team!

I was working with the ModifyOp class and discovered what I believe to be a bug with the deserialization from LDAP.

Here is a small snippet of code that I reproduces the error I'm seeing.

from ldaptor.delta import ModifyOp, Add, Delete

change_pw_op = ModifyOp(
    "cn=xander,dc=example,dc=com",
    [
        Delete(
            "unicodePwd", ['"{0}"'.format("old_password").encode("utf-16-le")]
        ),
        Add(
            "unicodePwd", ['"{0}"'.format("new_password").encode("utf-16-le")]
        )
    ]
)

ldap_req = change_pw_op.asLDAP()

new_op = ModifyOp.fromLDAP(ldap_req)

The output:

Traceback (most recent call last):
  File "/Users/xdesai/junk/python_weirdness/modify_op_bug.py", line 17, in <module>
    new_op = ModifyOp.fromLDAP(ldap_req)
  File "/Users/xdesai/junk/python_weirdness/3env/lib/python3.9/site-packages/ldaptor/delta.py", line 166, in fromLDAP
    for op, mods in request.modification:
ValueError: too many values to unpack (expected 2)

I dug into the code a bit. It seems to think that the modification field on the LDAPModifyRequest is a list of tuples because it tries to unpack it with this line for op, mods in request.modification:
but when I print the repr() of my LDAPModifyRequest. The modification field is just a list of byte strings.

LDAPModifyRequest(object='cn=xander,dc=example,dc=com', modification=[b'01\n\x01\x010,\x04\nunicodePwd1\x1e\x04\x1c"\x00o\x00l\x00d\x00_\x00p\x00a\x00s\x00s\x00w\x00o\x00r\x00d\x00"\x00', b'01\n\x01\x000,\x04\nunicodePwd1\x1e\x04\x1c"\x00n\x00e\x00w\x00_\x00p\x00a\x00s\x00s\x00w\x00o\x00r\x00d\x00"\x00'])

This where I started to get over my head so I decided to file an issue. Let me know if you have any questions!

  • Xander
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant