Skip to content

Commit

Permalink
Merge pull request alexferl#67 from nickolay/pr/groups
Browse files Browse the repository at this point in the history
Fix regression in groups-related functions (".." vs b"..")
  • Loading branch information
AdmiralObvious authored Mar 25, 2020
2 parents f4a6ab8 + 36f6944 commit 1e5b4b0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions flask_simpleldap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ def get_user_groups(self, user):
if current_app.config['LDAP_OPENLDAP']:
group_member_filter = \
current_app.config['LDAP_GROUP_MEMBER_FILTER_FIELD']
groups = [record[1][group_member_filter][0] for
record in records]
groups = [record[1][group_member_filter][0].decode(
'utf-8') for record in records]
return groups
else:
if current_app.config['LDAP_USER_GROUPS_FIELD'] in \
Expand All @@ -242,6 +242,7 @@ def get_user_groups(self, user):
current_app.config['LDAP_USER_GROUPS_FIELD']]
result = [re.findall(b'(?:cn=|CN=)(.*?),', group)[0]
for group in groups]
result = [r.decode('utf-8') for r in result]
return result
except ldap.LDAPError as e:
raise LDAPException(self.error(e.args))
Expand All @@ -266,6 +267,7 @@ def get_group_members(self, group):
records[0][1]:
members = records[0][1][
current_app.config['LDAP_GROUP_MEMBERS_FIELD']]
members = [m.decode('utf-8') for m in members]
return members
except ldap.LDAPError as e:
raise LDAPException(self.error(e.args))
Expand Down

0 comments on commit 1e5b4b0

Please sign in to comment.