mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
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 <akasurde@redhat.com>
This commit is contained in:
@@ -152,7 +152,7 @@ modlist:
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
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
|
from ansible.module_utils.ldap import LdapGeneric, gen_specs
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -173,9 +173,9 @@ class LdapAttr(LdapGeneric):
|
|||||||
|
|
||||||
# Normalize values
|
# Normalize values
|
||||||
if isinstance(self.module.params['values'], list):
|
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:
|
else:
|
||||||
self.values = [str(self.module.params['values'])]
|
self.values = [to_bytes(self.module.params['values'])]
|
||||||
|
|
||||||
def add(self):
|
def add(self):
|
||||||
values_to_add = filter(self._is_value_absent, self.values)
|
values_to_add = filter(self._is_value_absent, self.values)
|
||||||
|
|||||||
Reference in New Issue
Block a user