Skip to content

Commit 3123730

Browse files
committed
[16.0][DOC] add documentation for safe_ldap_decode()
1 parent 4bd1f8c commit 3123730

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

users_ldap_groups/models/res_company_ldap_operator.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ def _query(self, ldap_entry, mapping):
4545
return bool(results)
4646

4747
def safe_ldap_decode(self, attr):
48+
"""Safe LDAP decode; Base64 encode attributes containing binary data.
49+
Binary data can be stored in Active Directory, e.g., thumbnailPhoto is
50+
stored as binary. As Str.decoce() cannot handle binary, this method
51+
Base64 encodes the data in the attribute, instead, if decode fails.
52+
Using Base64 should be a suitable fallback, because the use cases of
53+
users_ldap_groups do not really require comparing binary attributes.
54+
"""
4855
try:
4956
return attr.decode()
5057
except UnicodeDecodeError:

0 commit comments

Comments
 (0)