Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...Get All users instead of AdminsGet All users instead of Admins
Previous
 
Next
New Post
3/23/2018 6:23 AM
 

I want to get all Registered users apart from Admins, Unauthenticated users and Superusers. I used the following SQL. But still, it is giving me Superusers. I need to avoid it too. Default Superuser role id is -2 on DNN 9.1.1

Please, advise.

 

SELECT Users.UserID, Users.Username,Users.FirstName, Users.LastName, Users.Email,UserRoles.RoleID

FROM UserRoles INNER JOIN

Users ON UserRoles.UserID = Users.UserID

WHERE (UserRoles.RoleID = 1) 

and  Users.userID not IN (SELECT UserID FROM UserRoles WHERE RoleID = 0 OR  RoleID =-2 OR  RoleID =-3)

 
New Post
3/23/2018 8:55 AM
Accepted Answer 
Negative Roles are "virtual Roles", which are used for permissions, but not assigned to any users (in UserRoles). Admins Role of Portal 0 usually have RoleID = 0, but this is not guaranteed.
To exclude Superusers, please use:
SELECT U.UserID,
U.Username,
U.FirstName,
U.LastName,
U.Email,
R.RoleID
FROM UserRoles R
JOIN Users U ON R.UserID = U.UserID
WHERE (R.RoleID = 1)
AND (U.IsSuperUser = 0)
and U.userID not IN (SELECT UserID FROM UserRoles WHERE RoleID = 0)

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
3/23/2018 8:59 AM
 
Wow. Thank you very much, Sebastian, for saving my time and life again :)
 
Previous
 
Next
HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...Get All users instead of AdminsGet All users instead of Admins


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out