dotnet / dotnet/aspnetcore

Give me all users and all of their roles...BY NAME

Open
#5,723 7 comments 0 reactions 0 assignees View on GitHub
affected-few area-identity enhancement severity-minor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

This is among the most simple of Use-Cases and yet does not appear to be allowed. When administering my site's users I need to be able to get a complete list of my users with their basic properties, one of which is the collection of roles assigned to the user. Using the ApplicationUser and UserManager "out of the box" and this code: _(ok, yes, mgr and org represent properties which have been added to ApplicationUser, but they don't change the present case)_

`var results = UserManager.Users.Where(u => u.mgr == appUser.org || appUser.org == "corp");`

I get all of the expected users ... but their "role" property only gives me the "RoleId" (and UserId) NOT the role's name. Since the database does enforce referential integrity between AspNetUserRoles and AspNetRoles it really SHOULD be a simple matter of including role names as part of this query...but does not appear to be so.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.