From 05e55bd3cb0ce220e1c3437f3626a45ec3703a10 Mon Sep 17 00:00:00 2001 From: angeloudy Date: Mon, 23 Jul 2018 15:49:00 +1000 Subject: [PATCH] values need to be bytes when writing to ldap --- salt/modules/ldap3.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/salt/modules/ldap3.py b/salt/modules/ldap3.py index 1ecf9bd3a61a..ad50924fc6ec 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: