From e3a073fdb90646928726b97ea7bcc6991884d9d2 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Fri, 8 Jun 2018 07:34:49 +0530 Subject: [PATCH] ldap_attr: Use byte values instead of str (#41248) The LDAP values may be of any kind (pictures, bytes, etc.) thus, ldap module enforce a "bytes" type. We should pass properly encoded values instead of str Fixes: #39569 Signed-off-by: Abhijeet Kasurde --- lib/ansible/modules/net_tools/ldap/ldap_attr.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/net_tools/ldap/ldap_attr.py b/lib/ansible/modules/net_tools/ldap/ldap_attr.py index 9212a314227..a3a50b07212 100644 --- a/lib/ansible/modules/net_tools/ldap/ldap_attr.py +++ b/lib/ansible/modules/net_tools/ldap/ldap_attr.py @@ -152,7 +152,7 @@ modlist: import traceback from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils._text import to_native +from ansible.module_utils._text import to_native, to_bytes from ansible.module_utils.ldap import LdapGeneric, gen_specs try: @@ -173,9 +173,9 @@ class LdapAttr(LdapGeneric): # Normalize values if isinstance(self.module.params['values'], list): - self.values = map(str, self.module.params['values']) + self.values = map(to_bytes, self.module.params['values']) else: - self.values = [str(self.module.params['values'])] + self.values = [to_bytes(self.module.params['values'])] def add(self): values_to_add = filter(self._is_value_absent, self.values)