Skip to content

Commit 873eea4

Browse files
committed
[FIX] users_ldap_populate: Decode login information
When iterating through the users from LDAP, if the login information is read in bytes, passing the value in bytes to the psycopg2 library doesn't work, failing with this error: ``` psycopg2.errors.UndefinedFunction: operator does not exist: text = bytea LINE 1: SELECT id FROM res_users WHERE lower(login)='... ``` so we need to decode the result before to get a pure string. TT56992
1 parent f00af93 commit 873eea4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

users_ldap_populate/models/users_ldap.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def action_populate(self):
6666
results = self._get_ldap_entry_dicts(conf)
6767
for result in results:
6868
login = result[1][login_attr][0].lower().strip()
69+
if isinstance(login, bytes):
70+
login = login.decode()
6971
user_id = None
7072
try:
7173
user_id = self.with_context(

0 commit comments

Comments
 (0)