Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6473609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:29:10+00:00 2026-05-25T06:29:10+00:00

When Roles are created/deleted I wouldn’t want to modify the code. if (HttpContext.Current.User.IsInRole(Super Admin)

  • 0

When Roles are created/deleted I wouldn’t want to modify the code.

if (HttpContext.Current.User.IsInRole("Super Admin") ||
    HttpContext.Current.User.IsInRole("Admin") ||
    HttpContext.Current.User.IsInRole("Support"))
{
    if (HttpContext.Current.User.IsInRole("Admin"))
    {
        ListBox1.DataSource = Roles.GetAllRoles().Except(
            new[] { "Super Admin" });

    }
    if (HttpContext.Current.User.IsInRole("Support"))
    {
        ListBox1.DataSource = Roles.GetAllRoles().Except(
            new[] { "Super Admin", "Admin" });
    }
    fillDropDownCustomers();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:29:10+00:00Added an answer on May 25, 2026 at 6:29 am

    Roles work by assigning a value to something a user can do. The Roles dont change but the behaviour for those roles does. Ultra dynamic solutions tend to be overkill.

    So perhaps you have the following roles

    • Super Admin
    • Support
    • Admin

    You can have different Actions (This would depend on your system)

    • View
    • Edit
    • Approve

    Etc

    • Super Admin [View, Edit, Approve]
    • Support [View]
    • Admin [View, Edit]

    The dynamic part comes in the assignment of Actions. Doing things this way you dont care what Role someone is in but what actions they have. The Actions are the dynamic aspect in this relationship. When a request is made you will use the users Role to fetch the assigned Actions to that role (Database Driven to make modifiable)

    Incorporating this into your Database structure as “Role has many Actions“, means that if things change in the future you will need to update the relationship in the database but not code.

    A database structure could look something like this, depends on your needs.

    • UserRole [ID, UserName, RoleID] (If user is assigned more than one role they inherit all actions, which might be duplicated and therefore selected DISTINCT or prevent this scenario, but I believe the former provides greater flexibility without complexity and limitation. NOTE: the UserRole table could be further denormalized to make UserNames unique.)
    • Role [ID, Name]
    • Action [ID, Name]
    • RoleAction [ID, RoleID, ActionID] (Unique Key Constraint on RoleID and ActionID)

    When a request is made, you identify the user etc UserName, Then workout which Role(s) they are in by quering the RoleAction and thereby load their associated Actions

    I would use enums for your Action and Role values. This makes it easier to work with. To ensure that the Database and Code are in sink, ensure that you write a Unit Test reconcile the database values against the enum values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m building a site that needs users created with different roles and permissions to
I would like to know how we can create different user Roles for different
I have a simple model: class User < ActiveRecord::Base has_and_belongs_to_many :roles end class Role
I want to create a trigger to check what is being deleted against business
I want to delete my git repository (.git folder) created by git on my
Problem ASP.NET has no concept of associating permissions to roles. My app Current web
roles = Role.find_all_by_simulation_id(session[:sim_id]) forum_posts = Post.find(:all, :conditions => [role_id = ? AND created_at >
If have created a custom role within SqlServer which I added to the db__denydatareader
I want to create extra rules in FXCop. Custom Rules to help ensure specific
My situation is a bit complex. I want to create $config rules for my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.