Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

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

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...SQL query to get user rolesSQL query to get user roles
Previous
 
Next
New Post
5/5/2009 1:21 PM
 

I want a user to see all other users with the same user roles.

Now I am breaking my head over the SQL query. I am using a third party module   "User Directory" and they have a filter function : I can set it to:

user_roles EQUALS  ".." On the dots I can fill in a number for example, but i want it to automatically checks the current user's role or roles and write that down. So : user_roles EQUALS "my roles". How can I get the numbers from  "my roles" from the DB?

Please help... thanks!

 
New Post
5/5/2009 3:01 PM
 

You should be able to do this with a free module (such as the REPORTS module).  For instance, using the free Advanced Datagrid module I've blogged about you can get what you want with the following query:
 
 select distinct u.username, r.rolename
 from users u
 inner join userroles ur on u.userid = ur.userid
 inner join userportals up on u.userid = up.userid
 inner join roles r on r.roleid = ur.roleid
 where up.portalid = [dnn:PortalID]
 and ur.roleid in
 (select ur1.roleid
  from userroles ur1
  where ur1.userid = [dnn:UserID])
 and (r.rolename != 'Registered Users')

 and (r.rolename != 'Subscribers')

 

  
Note the final two lines that filter out the results so that the "Registered Users" and "Subscribers" groups are not considered.  If you included the "Registered Users" group then all users with an account on the portal would always be listed.  Since "Subscribers" is usually auto-added to new accounts by default you'll want to filter that out as well unless you've changed your portal's default settings for the Subscribers group.
 
Final Note
Once you've gotten things working the way you like you should move your query into the database as a stored procedure.  Also note that this query as written is not very efficient -- it should work well for most people but could start to bog down if you have more than a few thousand accounts on your DNN installation.
 
Cheers!
-mamlin


esmamlin atxgeek.me
 
New Post
5/6/2009 6:17 AM
 

Thanks for your response.

The point is that I really want to use the Dataspings userdirectory module. So I am looking for the SQL query that will write down the ID's of my userroles.

Is there a simple  name for it, for example : dbo.userroles(myroles) ?

Thanks in advance!

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...SQL query to get user rolesSQL query to get user roles


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