Skip to content

Commit

Permalink
values need to be bytes when writing to ldap
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloudy authored and rallytime committed Oct 9, 2018
1 parent 0d749e6 commit 05e55bd
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions salt/modules/ldap3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 05e55bd

Please sign in to comment.