Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
python-ldap bug under pypy
#!/usr/bin/env python
#
# This codes demonstrate a bug while running this code under pypy.
# (you need to be on-line to run this code, to be able to access
# the demo ldap server at ldap://ipa.demo1.freeipa.org)
#
# When the search query below is executed under pypy, the attributes
# list will be mangled while being converted to C format, this we
# will get an empty result.
#
import ldap
SERVER = "ldap://ipa.demo1.freeipa.org"
BASE_DN = "cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org"
FILTER = "uid=admin"
l = ldap.initialize(SERVER)
l.simple_bind()
res = l.search_s(BASE_DN,
ldap.SCOPE_SUBTREE,
FILTER,
["uid", "cn"]) # these string will be mangled
print res
#
# expected output:
#
# [('uid=admin,cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org',
# {'uid': ['admin'], 'cn': ['Administrator']})]
#
# under pypy, the attributes dictionary will be empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.