diff --git a/salt/modules/ldap3.py b/salt/modules/ldap3.py index 9b11745709cb..30452f55e7b0 100644 --- a/salt/modules/ldap3.py +++ b/salt/modules/ldap3.py @@ -402,18 +402,14 @@ def add(connect_spec, dn, attributes): # convert the "iterable of values" to lists in case that's what # addModlist() expects (also to ensure that the caller's objects # are not modified) - attributes = dict(((attr, list(vals)) + attributes = dict(((attr, salt.utils.data.encode(list(vals))) for attr, vals in six.iteritems(attributes))) log.info('adding entry: dn: %s attributes: %s', repr(dn), repr(attributes)) if 'unicodePwd' in attributes: attributes['unicodePwd'] = [_format_unicode_password(x) for x in attributes['unicodePwd']] - modlist = salt.utils.data.decode( - ldap.modlist.addModlist(attributes), - to_str=True, - preserve_tuples=True - ) + modlist = ldap.modlist.addModlist(attributes), try: l.c.add_s(dn, modlist) except ldap.LDAPError as e: @@ -572,19 +568,16 @@ def change(connect_spec, dn, before, after): # convert the "iterable of values" to lists in case that's what # modifyModlist() expects (also to ensure that the caller's dicts # are not modified) - before = dict(((attr, list(vals)) + before = dict(((attr, salt.utils.data.encode(list(vals))) for attr, vals in six.iteritems(before))) - after = dict(((attr, list(vals)) + after = dict(((attr, salt.utils.data.encode(list(vals))) for attr, vals in six.iteritems(after))) if 'unicodePwd' in after: after['unicodePwd'] = [_format_unicode_password(x) for x in after['unicodePwd']] - modlist = salt.utils.data.decode( - ldap.modlist.modifyModlist(before, after), - to_str=True, - preserve_tuples=True - ) + modlist = ldap.modlist.modifyModlist(before, after) + try: l.c.modify_s(dn, modlist) except ldap.LDAPError as e: