Skip to content

Commit

Permalink
[16.0][DOC] add documentation for safe_ldap_decode()
Browse files Browse the repository at this point in the history
  • Loading branch information
oh2fih committed Jun 4, 2024
1 parent 4bd1f8c commit 3123730
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions users_ldap_groups/models/res_company_ldap_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3123730

Please sign in to comment.