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

ldap.dn.str2dn('cn=foo\\?,dc=base') #296

Closed
spaceone opened this issue Aug 2, 2019 · 4 comments
Closed

ldap.dn.str2dn('cn=foo\\?,dc=base') #296

spaceone opened this issue Aug 2, 2019 · 4 comments

Comments

@spaceone
Copy link
Contributor

spaceone commented Aug 2, 2019

An ldap search in a Samba 4 LDAP directory returns DN's containing a ? escaped as \?.
This fails to get parsed:

>>> import ldap.dn
>>> ldap.dn.str2dn('cn=foo\\?,dc=base')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/ldap/dn.py", line 53, in str2dn
    return ldap.functions._ldap_function_call(None,_ldap.str2dn,dn,flags)
  File "/usr/lib/python2.7/dist-packages/ldap/functions.py", line 66, in _ldap_function_call
    result = func(*args,**kwargs)
ldap.DECODING_ERROR

As a workaround I am using a function like:

def str2dn(dn):
       try:
               return ldap.dn.str2dn(dn)
       except ldap.DECODING_ERROR:
               return ldap.dn.str2dn(dn.replace('\\?', '?'))

Just wanted to let you know. I am unsure If this is an error in the Samba 4 LDAP implementation or if this is acutally allowed LDAP syntax.

@spaceone
Copy link
Contributor Author

spaceone commented Aug 2, 2019

Maybe related to: #257

@quanah
Copy link
Contributor

quanah commented Aug 2, 2019

I would compare vs OpenLDAP's behavior with a similar DN.

@tiran
Copy link
Member

tiran commented Aug 6, 2019

Please report this bug with OpenLDAP. python-ldap uses libldap's ldap_bv2dn() to parse the string.

@spaceone
Copy link
Contributor Author

spaceone commented Aug 6, 2019

I created a bug at Samba: https://bugzilla.samba.org/show_bug.cgi?id=14073

@spaceone spaceone closed this as completed Aug 6, 2019
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

3 participants