From 33add86b0e06f51a2867eb437dd823e4cb43a6d4 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 15 Sep 2023 19:01:32 +0200 Subject: [PATCH] ldap_search: make sure to also handle binary strings in Python 3 (#7264) Make sure to also handle binary strings in Python 3. --- changelogs/fragments/7264-ldap_search-strings.yml | 2 ++ plugins/modules/ldap_search.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/7264-ldap_search-strings.yml diff --git a/changelogs/fragments/7264-ldap_search-strings.yml b/changelogs/fragments/7264-ldap_search-strings.yml new file mode 100644 index 00000000000..75bef2194e9 --- /dev/null +++ b/changelogs/fragments/7264-ldap_search-strings.yml @@ -0,0 +1,2 @@ +bugfixes: + - "ldap_search - fix string normalization and the ``base64_attributes`` option on Python 3 (https://github.com/ansible-collections/community.general/issues/5704, https://github.com/ansible-collections/community.general/pull/7264)." diff --git a/plugins/modules/ldap_search.py b/plugins/modules/ldap_search.py index d5e3265f0de..45744e634a7 100644 --- a/plugins/modules/ldap_search.py +++ b/plugins/modules/ldap_search.py @@ -120,7 +120,7 @@ from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text -from ansible.module_utils.six import string_types, text_type +from ansible.module_utils.six import binary_type, string_types, text_type from ansible_collections.community.general.plugins.module_utils.ldap import LdapGeneric, gen_specs, ldap_required_together LDAP_IMP_ERR = None @@ -159,7 +159,7 @@ def main(): def _normalize_string(val, convert_to_base64): - if isinstance(val, string_types): + if isinstance(val, (string_types, binary_type)): if isinstance(val, text_type): val = to_bytes(val, encoding='utf-8') if convert_to_base64: