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

HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...Update user security role - SQLUpdate user security role - SQL
Previous
 
Next
New Post
12/25/2018 6:24 AM
 

Hi,

I want to update user's security role through an SQL. What is the complete correct UPDATE SQL to update th user security role?

Please, advise me.

Thank you.

 
New Post
12/27/2018 4:56 AM
 
Do you want to add or remove or update a role membership for a single user or multiple users?

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
12/27/2018 5:07 AM
 
Hi Sebastian,

Basically, I need to add a user role for the users thorough and SQL. I know who are the users. The usernames. I have about 10 new user roles. I need to give their user role based on their points. I have a points system and calculating and updating through an SQL. if they reach the points for the user role, I need to give their user role.

So Please tell me
1) How to add a user role for each user if we know the username.
2) How can we remove other user roles for him and add a new user role?

Appreciate your support.

Thank you.
 
New Post
12/27/2018 5:29 AM
 
Hi Y Ma,
You should lookup RoleID from Roles Table - that's a bit easier than handling with RoleName and PortalID.

To assign a user to a role, you need to add a record to UserRoles table. The best option would be a Merge statement:

MERGE INTO dbo.UserRoles T
USING (SELECT @RoleID AS RoleID, UserID FROM dbo.UserPoints WHERE PointCount > 100) AS S ON T.UserID = S.UserID AND T.RoleID = S.RoleID
WHEN NOT MATCHED THEN INSERT (RoleID, UserID, Status) VALUES (S.RoleID, S.UserID, 1)

You may adopt the SELECT according to your table(s) to obtain the UserIDs to add.

Please be aware that you'll need to clear the portal cache in order for database changes to become effective.

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
12/27/2018 5:31 AM
 
You also might want to have a look at this module, if you need to update role memberships frequently:
https://store.dnnsoftware.com/home/pr...

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
Previous
 
Next
HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...Update user security role - SQLUpdate user security role - SQL


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