Questions tagged [asp.net-roles]

ASP.NET role management helps you to manage authorization, allowing you to specify which resources various users in your application are allowed to access. Role management lets you group users by assigning them to roles.

226 questions
44
votes
7 answers

Add User to Role ASP.NET Identity

I know the new Membership includes a "Simple Role Provider." I can't find any help related to creating a user and assigning a role when the user is created. I've added a user which created the tables on the DB correctly. I see the AspNetRoles,…
Brad Martin
  • 5,637
  • 4
  • 28
  • 44
18
votes
4 answers

ASP.NET MVC3 Role and Permission Management -> With Runtime Permission Assignment

ASP.NET MVC allows users the ability to assign permissions to functionality (i.e. Actions) at Design Time like so. [Authorize(Roles = "Administrator,ContentEditor")] public ActionResult Foo() { return View(); } To actually check the permission,…
18
votes
2 answers

Policy-based authorization vs authorize with role in .Net Core

What is the difference between using policy-based authorization and authorize with role, or there is no difference? [Authorize(Policy = "RequiredAdminRole")] and [Authorize(Roles = "Admin")]
Hasan Darwish
  • 385
  • 2
  • 6
  • 21
18
votes
5 answers

Trying to get all roles in Identity

I am trying to get a list of all the roles in my application. I have looked at the following post Getting All Users... and other sources. Here is my code which I think is what I am supposed to do. var roleStore = new…
physics90
  • 946
  • 3
  • 9
  • 24
13
votes
3 answers

ASP.NET Identity, add another user to role instantly (they don't have to log out and in again)

First of all, I'm aware of this question: MVC 5 AddToRole requires logout before it works? and this one: What is ASP.NET Identity's IUserSecurityStampStore interface? so please don't mark this as a duplicate. I'm trying to add another user to…
nmit026
  • 3,024
  • 2
  • 27
  • 53
13
votes
5 answers

List of Users with roles in MVC Asp.net identity

I want to have list of all the users registered on my site with their roles. Id | Name | Role 1 | ABC | Admin 2 | DEF | User Something like this, I have made Roles controller in which all the roles is listed. public ActionResult Index() …
Rras
  • 163
  • 1
  • 1
  • 9
12
votes
4 answers

Get Role name in IdentityUserRole 2.0 in ASP.NET

Before the update of the dll's in the Entity Framework i was able to do this user.Roles.Where(r => r.Role.Name == "Admin").FisrtOrDefault(); Now, i can only do r.RoleId, and i can't find a way to retreive the name of thar Role Id. I'm using this…
MarBVI
  • 811
  • 2
  • 12
  • 34
11
votes
3 answers

How to best handle permissions (not roles) in asp.net membership, specifically in ASP.NET MVC

There are plenty of questions (and information) on setting up asp.net membership, role providers and the like. Whether or not you should use the built in platform provided by microsoft, or role extend the base classes and role your own. I have…
11
votes
1 answer

Hide link based on Role

Im new to asp.mvc. I'm trying to develop a portal to maintain employee data. In my system only "Manager" has the rigths to create employee. How do I enable the link when manager log in and disable when employee log in. Thanks My View @model…
chinna_82
  • 6,353
  • 17
  • 79
  • 134
9
votes
3 answers

ASP.NET Login Redirect Loop when user not in role

I'm in a bit of a bind with implementing Roles in ASP.NET MVC 5. I am attempting to log in as a user that does not have a role required to access the area of the application I'm trying to reach. What I would expect in this scenario is, I'm…
9
votes
5 answers

AuthorizeAttribute with ASP.NET Identity

I have a controller which is protected by the [Authorize] attribute. This works very good (I am sent back to login if I am not logged in), but I wish to add some roles to this attribute, I've read that its possible to do something like…
janhartmann
  • 14,713
  • 15
  • 82
  • 138
8
votes
2 answers

ASP.NET MVC Single Sign-on and Roles

I have basic Single Sign-On working across 2 MVC sites (call them SiteA and SiteB) using something along the lines of the following method: http://forums.asp.net/p/1023838/2614630.aspx They are on sub-domains of the same domain and share…
mutex
  • 7,536
  • 8
  • 45
  • 66
6
votes
2 answers

Why are the primary keys generated by aspnet_regsql GUIDs?

I am developing an ASP.NET website in Visual Studio 2010 (with Service Pack 1, thank you very much). I want to utilize .NET's built-in Membership and Role providers for SQL Server 2008. Now, I've been developing Microsoft technologies for a very…
dotnettex
  • 74
  • 2
6
votes
1 answer

I created an empty project (MVC) but now want user roles and profiles tables added to my db

When you create an MVC Application with Windows Authentication, it adds roles and what not to your database tables... How do you add those in manually if you have created the project as an empty project? I have run:…
Jimmyt1988
  • 20,466
  • 41
  • 133
  • 233
6
votes
1 answer

Adding Role dynamically in new VS 2013 Identity UserManager

I created a new MVC application in the new VS2013 IDE. I added the following to the Login Action on the AccountController as I wanted to create a default user dynamically: var admin = new ApplicationUser() { UserName = "administrator" }; var result…
user1166905
  • 2,612
  • 7
  • 43
  • 75
1
2 3
15 16