diff --git a/changelogs/fragments/7264-ldap_search-strings.yml b/changelogs/fragments/7264-ldap_search-strings.yml new file mode 100644 index 0000000000..75bef2194e --- /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 d5e3265f0d..45744e634a 100644 --- a/plugins/modules/ldap_search.py +++ b/plugins/modules/ldap_search.py @@ -120,7 +120,7 @@ import traceback 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: