roles

No service for type Identity.UserManager when using multiple identity users

旧街凉风 提交于 2019-11-30 01:54:40
问题 My setup Currently, I have two models that inherit from ApplicationUser , which inherits IdentityUser . The user classes are: public abstract class ApplicationUser : IdentityUser { [PersonalData] public string FirstName { get; set; } [PersonalData] public string LastName { get; set; } [NotMapped] public string FullName => $"{FirstName} {LastName}"; } public class StudentUser : ApplicationUser { [PersonalData] [Required] public string StudentNumber { get; set; } // A user belongs to one group

ASP.Net MVC 3 Redirect UnAuthorized User not to loginUrl

穿精又带淫゛_ 提交于 2019-11-29 22:24:17
i have a project using ASP.Net MVC3 and using membership for roles. i use authorize in every controller. eg: [Authorize(Roles = "Administrator")] public ActionResult Index(string q, int i) { return View(model); } if someone doesnt have role for administrator, then it will redirect to login page by default. how to change it,so it will redirect into Views/Shared/UnAuthorize.cshtml ? or maybe if someone doesnt have role for administrator, it will show message box (alert) ? thanks in advance. Just change the page that have to be shown in the web.config (check that the route exists) <authentication

Create PostgreSQL ROLE (user) if it doesn't exist

情到浓时终转凉″ 提交于 2019-11-29 20:32:08
How do I write an SQL script to create a ROLE in PostgreSQL 9.1, but without raising an error if it already exists? The current script simply has: CREATE ROLE my_user LOGIN PASSWORD 'my_password'; This fails if the user already exists. I'd like something like: IF NOT EXISTS (SELECT * FROM pg_user WHERE username = 'my_user') BEGIN CREATE ROLE my_user LOGIN PASSWORD 'my_password'; END; ... but that doesn't work - IF doesn't seem to be supported in plain SQL. I have a batch file that creates a PostgreSQL 9.1 database, role and a few other things. It calls psql.exe, passing in the name of an SQL

Handling Multiple Roles in MVC - Action-based Accessibility

不羁的心 提交于 2019-11-29 20:31:24
I currently have a project that I seem to have ran into an issue regarding Roles and thought I would get some opinions on how to best handle the problem. The system will require editable, flexible roles that control not only the access of specific areas, but also the use of system functions (Adding Users, Editing Users, Viewing Reports etc.) The system currently allows users to have multiple roles, each of those roles has explicitly defined areas of access/actions, for example: Role A can access areas 1,2,3 and can Add Users. Role B can access areas 1,5,7 and can Modify Users. Role C can

Best Practices for Roles vs. Claims in ASP.NET Identity

拥有回忆 提交于 2019-11-29 18:54:51
I am completely new to the use of claims in ASP.NETIdentity and want to get an idea of best practices in the use of Roles and/or Claims . After all this reading, I still have questions like... Q: Do we no longer use Roles? Q: If so, why are Roles still offered? Q: Should we only use Claims? Q: Should we use Roles & Claims together? My initial thought is that we "should" use them together. I see Claims as sub-categories to the Roles they support. FOR EXAMPLE: Role: Accounting Claims : CanUpdateLedger, CanOnlyReadLedger, CanDeleteFromLedger Q: Are they intended to be mutually exclusive? Q: Or is

Spring Security Role Prefix and Custom User Details Service

让人想犯罪 __ 提交于 2019-11-29 15:29:01
How do I set the role prefix to "" with a custom user details service in Spring? <beans:bean id="authService" class="com.cisco.badges.business.services.AuthenticationService"/> <authentication-manager> <authentication-provider user-service-ref="authService"> <password-encoder ref="passwordEncoder"> <salt-source ref="saltSource" /> </password-encoder> </authentication-provider> </authentication-manager> @Service("authService") public class AuthenticationService extends BaseService implements UserDetailsService, IAuthenticationService { @Autowired IUserRepository userRepository; @Autowired

building Role based application

五迷三道 提交于 2019-11-29 15:00:52
问题 I have to make a small website where I have 7 type of users. which can login into system. some of users have permissions to only add equipments and others can add/edit. some of them can only view. There will be some common fields for all users adding equipments in system and some fields will be user specific. I have to track all changes in equipments with user changing equipments. Can any one explain what will be best way to do this job. Way in the sense table structure for users and tracking

Set Property Value on Master Page from Content Page

大城市里の小女人 提交于 2019-11-29 14:11:19
问题 I need to pass data to a variable in my master page each time a page is loaded. I have a string[] of RequiredRoles that I set on each content page defining what roles are required to access that page. On my master page, I have a method that takes this array, and checks to see if the current user is in one or more of those roles. How would I go about managing this? I basically want each page to have a String[] RequiredRoles defined, and the master page will load this on each call and check to

Mvc Runtime error - The Role Manager feature has not been enabled

孤街浪徒 提交于 2019-11-29 10:52:12
I am trying to implement basic role management manually. When a user logs in if they are admin or not they are added to a role I am getting this error: Exception Details: System.Configuration.Provider.ProviderException: The Role Manager feature has not been enabled. This is the method that causes the error: public void addUserToRole(String user, String role) { if (!Roles.RoleExists(role)) Roles.CreateRole(role); Roles.AddUserToRole(user, role); } here is my web.config <profile defaultProvider="DefaultProfileProvider"> <providers> <add name="DefaultProfileProvider" type="System.Web.Providers

SQL Server - Give a Login Permission for Read Access to All Existing and Future Databases

耗尽温柔 提交于 2019-11-29 10:23:54
I have a stored procedure that finds all the existing databases and reads from a table in each one. Is there a way I can give a login read access to all databases, and to all future databases i.e., I won't have to do anything when a new database is added? Is there a server role that would work? Is there a way to make a SQL agent job add the permissions on any new databases? Or is there some other method? For new databases, add the user in the model database. This is used as the template for all new databases. USE model CREATE USER ... FROM LOGIN... EXEC sp_addrolemember 'db_datareader', '...'