From 31237303d50402ff4e3bb42975674e3bb086ca70 Mon Sep 17 00:00:00 2001 From: Esa Jokinen Date: Tue, 4 Jun 2024 18:28:02 +0300 Subject: [PATCH] [16.0][DOC] add documentation for safe_ldap_decode() --- users_ldap_groups/models/res_company_ldap_operator.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/users_ldap_groups/models/res_company_ldap_operator.py b/users_ldap_groups/models/res_company_ldap_operator.py index e26b9d38cb..0d889c461a 100644 --- a/users_ldap_groups/models/res_company_ldap_operator.py +++ b/users_ldap_groups/models/res_company_ldap_operator.py @@ -45,6 +45,13 @@ def _query(self, ldap_entry, mapping): return bool(results) def safe_ldap_decode(self, attr): + """Safe LDAP decode; Base64 encode attributes containing binary data. + Binary data can be stored in Active Directory, e.g., thumbnailPhoto is + stored as binary. As Str.decoce() cannot handle binary, this method + Base64 encodes the data in the attribute, instead, if decode fails. + Using Base64 should be a suitable fallback, because the use cases of + users_ldap_groups do not really require comparing binary attributes. + """ try: return attr.decode() except UnicodeDecodeError: