From f6b2adfaec790c93306254a0522d5d02d7d639fa Mon Sep 17 00:00:00 2001 From: Esa Jokinen Date: Tue, 4 Jun 2024 18:32:13 +0300 Subject: [PATCH] [16.0][DOC] add documentation for safe_ldap_decode() --- users_ldap_groups/models/res_company_ldap_operator.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/users_ldap_groups/models/res_company_ldap_operator.py b/users_ldap_groups/models/res_company_ldap_operator.py index 158ac78a86..25db85ea7b 100644 --- a/users_ldap_groups/models/res_company_ldap_operator.py +++ b/users_ldap_groups/models/res_company_ldap_operator.py @@ -45,6 +45,14 @@ 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: