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

preserve tuples for ldap modification operations #48258

merged 1 commit into from Jun 22, 2018


None yet
4 participants

nullify005 commented Jun 22, 2018

What does this PR do?

Preserves the tuples which are passed into the decoding method for ldap modify operations

What issues does this PR fix or reference?

Fixes #46887 (comment)


          ID: slapd suffix
    Function: ldap.managed
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/", line 1905, in call
                File "/usr/lib/python2.7/dist-packages/salt/", line 1830, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/states/", line 334, in managed
                  __salt__['ldap3.add'](l, dn, n)
                File "/usr/lib/python2.7/dist-packages/salt/modules/", line 417, in add
                  l.c.add_s(dn, modlist)
                File "/usr/lib/python2.7/dist-packages/ldap/", line 209, in add_s
                  msgid = self.add(dn,modlist)
                File "/usr/lib/python2.7/dist-packages/ldap/", line 206, in add
                  return self.add_ext(dn,modlist,None,None)
                File "/usr/lib/python2.7/dist-packages/ldap/", line 191, in add_ext
                  return self._ldap_call(self._l.add_ext,dn,modlist,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls))
                File "/usr/lib/python2.7/dist-packages/ldap/", line 106, in _ldap_call
                  result = func(*args,**kwargs)
              TypeError: ('expected a tuple', ['objectClass', ['top', 'dcObject', 'organization']])
     Started: 03:49:06.574923
    Duration: 7.598 ms

Which I traced to this in modules/ before & after the

[DEBUG   ] ====> modlist before: [(0, u'olcRootPW', [u'{SSHA}whatever'])]
[DEBUG   ] ====> modlist after: [[0, 'olcRootPW', ['{SSHA}whatever']]]

Notice that the inner tuple gets converted to a list which the underlying ldap library isn't fond of

Turning on preserve_tuples fixes the issue

Previous Behavior

ldap modify operations fail

New Behavior

ldap modify operations succeed

Tests written?


Commits signed with GPG?



This comment has been minimized.


nullify005 commented Jun 22, 2018

Can we also get this backported to 2018.3 pretty please?


This comment has been minimized.

julientravelaer commented Jun 22, 2018

FYI: Tested & approved, it fixes ldap entries creations & modifications.


terminalmage approved these changes Jun 22, 2018 edited

@rallytime this needs a backport to 2018.3

EDIT: nvm I see you're already on top of it 😄


This comment has been minimized.


rallytime commented Jun 22, 2018

@nullify005 I am happy to backport this, but in the future, feel free to submit bug fixes to their appropriate branches. We will then merge them forward. You can learn more here if you're interested on how we manage this. :)

@rallytime rallytime merged commit 254f8fc into saltstack:develop Jun 22, 2018

6 of 10 checks passed

jenkins/PR/salt-pr-linode-ubuntu16-py3 Pull Requests » Salt PR - Linode Ubuntu16.04 - PY3 #10917 — ABORTED
default Build finished.
jenkins/PR/salt-pr-linode-cent7-py3 Pull Requests » Salt PR - Linode CentOS 7 - PY3 #5947 — FAILURE
jenkins/PR/salt-pr-rs-cent7-n Pull Requests » Salt PR - RS CentOS 7 #20000 — FAILURE
WIP ready for review
codeclimate All good!
jenkins/PR/salt-pr-clone Pull Requests » Salt PR - Clone #26151 — SUCCESS
jenkins/PR/salt-pr-docs-n Pull Requests » Salt PR - Docs #18201 — SUCCESS
jenkins/PR/salt-pr-linode-ubuntu14-n Pull Requests » Salt PR - Linode Ubuntu14.04 #23875 — SUCCESS
jenkins/PR/salt-pr-lint-n Pull Requests » Salt PR - Code Lint #22836 — SUCCESS

rallytime added a commit that referenced this pull request Jun 25, 2018

xenophonf added a commit to irtnog/salt-states that referenced this pull request Oct 17, 2018

fix(salt.modules.ldap3): backport ldap3 execution modules fixes in 20…

The following PR fixes the `expected a tuple` error when modifying
LDAP objects:


See also this issue:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment