简体   繁体   English

查询以获取DNN中的用户角色

[英]Query to get user roles in DNN

I need a query to see which Roles users have in DotNetNuke. 我需要查询以查看用户在DotNetNuke中具有哪些角色。 I found this query but it gives the RoleID and not the name. 我发现此查询,但它提供了RoleID而不是名称。 What if there are more than one role associated to a user? 如果一个用户有多个角色,该怎么办?

SELECT Users.FirstName, Users.LastName, Users.Email,UserRoles.RoleID
FROM UserRoles 
INNER JOIN Users ON UserRoles.UserID = Users.UserID

You need to include the Roles table in your query if you want the Role Names. 如果需要角色名称,则需要在查询中包括“ Roles表。

SELECT Users.FirstName, Users.LastName, Users.Email, UserRoles.RoleID, Roles.RoleName
FROM UserRoles 
INNER JOIN Users ON UserRoles.UserID = Users.UserID 
INNER JOIN Roles ON UserRoles.RoleID = Roles.RoleID
WHERE (Roles.PortalID = 0)

You also might want to include the PortalID to avoid duplicates from other portals. 您可能还希望包括PortalID,以避免其他门户网站重复。 However I would recommend to use the DNN core functionalities do determine a user role, with the RoleController . 但是,我建议使用RoleController与DNN核心功能一起确定用户角色。

If there are 2 roles for a user it will bring 2 rows for the same user with different RoleID. 如果一个用户有2个角色,它将为具有不同RoleID的同一用户带来2行。 n rows for n roles. n行代表n个角色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM