Skip to content

Commit 1e5b4b0

Browse files
Merge pull request #67 from nickolay/pr/groups
Fix regression in groups-related functions (".." vs b"..")
2 parents f4a6ab8 + 36f6944 commit 1e5b4b0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

flask_simpleldap/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ def get_user_groups(self, user):
232232
if current_app.config['LDAP_OPENLDAP']:
233233
group_member_filter = \
234234
current_app.config['LDAP_GROUP_MEMBER_FILTER_FIELD']
235-
groups = [record[1][group_member_filter][0] for
236-
record in records]
235+
groups = [record[1][group_member_filter][0].decode(
236+
'utf-8') for record in records]
237237
return groups
238238
else:
239239
if current_app.config['LDAP_USER_GROUPS_FIELD'] in \
@@ -242,6 +242,7 @@ def get_user_groups(self, user):
242242
current_app.config['LDAP_USER_GROUPS_FIELD']]
243243
result = [re.findall(b'(?:cn=|CN=)(.*?),', group)[0]
244244
for group in groups]
245+
result = [r.decode('utf-8') for r in result]
245246
return result
246247
except ldap.LDAPError as e:
247248
raise LDAPException(self.error(e.args))
@@ -266,6 +267,7 @@ def get_group_members(self, group):
266267
records[0][1]:
267268
members = records[0][1][
268269
current_app.config['LDAP_GROUP_MEMBERS_FIELD']]
270+
members = [m.decode('utf-8') for m in members]
269271
return members
270272
except ldap.LDAPError as e:
271273
raise LDAPException(self.error(e.args))

0 commit comments

Comments
 (0)