Skip to content

Commit

Permalink
improve error message for return_user_by_name
Browse files Browse the repository at this point in the history
  • Loading branch information
claire-peters committed Sep 4, 2024
1 parent ea91618 commit 495aeea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions coldfront/plugins/ldap/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ def return_user_by_name(self, username, return_as='dict', attributes=ALL_ATTRIBU
"""Return an AD user entry by the username"""
user = self.search_users({"uid": username}, return_as=return_as, attributes=attributes)
if len(user) > 1:
raise ValueError("too many users in value returned")
raise ValueError(f"too many users in value returned for username {username}")
if not user:
raise ValueError("no users returned")
raise ValueError(f"no users returned for username {username}")
return user[0]

def return_group_by_name(self, groupname, return_as='dict', attributes=ALL_ATTRIBUTES):
Expand Down

0 comments on commit 495aeea

Please sign in to comment.