Page MenuHomePhorge

encode_page_control() argument 2 must be string or read-only buffer
Closed, ResolvedPublic

Description

While running kolab sync I stumpled across the following traceback

2019-12-22 21:31:51,913 pykolab.auth DEBUG [25051] Synchronization is using filter '(&(|(objectclass=kolabinetorgperson)(|(objectclass=kolabgroupofuniquenames)(objectclass=kolabgroupofurls))(|(|(objectclass=groupofuniquenames)(objectclass=groupofurls))(objectclass=kolabsharedfolder))(objectclass=kolabsharedfolder))(modifytimestamp>=19000101000000Z))'
2019-12-22 21:31:51,914 pykolab.auth DEBUG [25051] Searching root dn for domain 'DOMAIN'
2019-12-22 21:31:51,915 pykolab.auth DEBUG [25051] bind() called but already bound
2019-12-22 21:31:51,915 pykolab.auth DEBUG [25051] Finding domain root dn for domain DOMAIN
2019-12-22 21:31:51,915 pykolab.auth DEBUG [25051] Searching with filter '(&(associatedDomain=DOMAIN))'
2019-12-22 21:31:51,916 pykolab.auth DEBUG [25051]  *** <ldap.ldapobject.ReconnectLDAPObject instance at 0x7fbc36930908> ldap://localhost:389 - ReconnectLDAPObject.search_ext
2019-12-22 21:31:51,917 pykolab.auth DEBUG [25051]  (('ou=Domains,ROOTDN',
2019-12-22 21:31:51,917 pykolab.auth DEBUG [25051]    2,
2019-12-22 21:31:51,917 pykolab.auth DEBUG [25051]    '(&(associatedDomain=DOMAIN))',
2019-12-22 21:31:51,918 pykolab.auth DEBUG [25051]    None,
2019-12-22 21:31:51,918 pykolab.auth DEBUG [25051]    0,
2019-12-22 21:31:51,918 pykolab.auth DEBUG [25051]    None,
2019-12-22 21:31:51,919 pykolab.auth DEBUG [25051]    None,
2019-12-22 21:31:51,919 pykolab.auth DEBUG [25051]    -1,
2019-12-22 21:31:51,920 pykolab.auth DEBUG [25051]    0),
2019-12-22 21:31:51,920 pykolab.auth DEBUG [25051]   {})
2019-12-22 21:31:51,921 pykolab.auth DEBUG [25051]  *** <ldap.ldapobject.ReconnectLDAPObject instance at 0x7fbc36930908> ldap://localhost:389 - ReconnectLDAPObject.result4
2019-12-22 21:31:51,922 pykolab.auth DEBUG [25051]  ((2, False, 0, 0, 0, 0), {})
2019-12-22 21:31:51,922 pykolab.auth DEBUG [25051]  *** <ldap.ldapobject.ReconnectLDAPObject instance at 0x7fbc36930908> ldap://localhost:389 - ReconnectLDAPObject.result4
2019-12-22 21:31:51,923 pykolab.auth DEBUG [25051]  ((2, False, 0, 0, 0, 0), {})
2019-12-22 21:31:51,923 pykolab.auth DEBUG [25051] Setting domain root dn from LDAP for domain 'DOMAIN': 'ROOTDN'
2019-12-22 21:31:51,924 pykolab.auth DEBUG [25051] Synchronization is searching against base DN: ROOTDN
2019-12-22 21:31:51,924 pykolab.auth ERROR [25051] An error occured using _paged_search: TypeError('encode_page_control() argument 2 must be string or read-only buffer, not None',)
2019-12-22 21:31:51,925 pykolab.auth ERROR [25051] Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pykolab/auth/ldap/__init__.py", line 3169, in _search
    secondary_domains
  File "<string>", line 10, in <module>
  File "/usr/lib/python2.7/dist-packages/pykolab/auth/ldap/__init__.py", line 2908, in _paged_search
    serverctrls=[server_page_control]
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 839, in search_ext
    RequestControlTuples(serverctrls),
  File "/usr/lib/python2.7/dist-packages/ldap/controls/__init__.py", line 119, in RequestControlTuples
    for c in ldapControls
  File "/usr/lib/python2.7/dist-packages/ldap/controls/libldap.py", line 77, in encodeControlValue
    return _ldap.encode_page_control(self.size,self.cookie)
TypeError: encode_page_control() argument 2 must be string or read-only buffer, not None

It looks like the Page control must be changed to support a 2nd argument.

/usr/lib/python2.7/dist-packages/pykolab/auth/ldap/__init__.py

Line 2899 - before:

server_page_control = ldap.controls.libldap.SimplePagedResultsControl(size=page_size)

Line 2899 - after:

server_page_control = ldap.controls.libldap.SimplePagedResultsControl(size=page_size,cookie='')

After this change, the kolab sync was running fine.

Details

Ticket Type
Task

Event Timeline

dhoffend added a subscriber: PyKolab Developers.

This happend on a Debian 10 system with most recent pykolab package

  • pykolab 0.8.17-0~kolab2
  • python-ldap 3.1.0-2

Additionally I get the following traceback:

2019-12-23 14:05:25,670 pykolab.auth ERROR [21425] An error occured using _paged_search: NameError("global name 'LDAP_CONTROL_PAGED_RESULTS' is not defined",)
2019-12-23 14:05:25,670 pykolab.auth ERROR [21425] Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pykolab/auth/ldap/__init__.py", line 3168, in _search
    secondary_domains
  File "<string>", line 10, in <module>
  File "/usr/lib/python2.7/dist-packages/pykolab/auth/ldap/__init__.py", line 2940, in _paged_search
    if c.controlType == LDAP_CONTROL_PAGED_RESULTS
NameError: global name 'LDAP_CONTROL_PAGED_RESULTS' is not defined
dhoffend claimed this task.

Closing Ticket. Change has been merged