roles

asp.net membership - how to determine programmatically is user is in role

送分小仙女□ 提交于 2019-12-18 05:43:46
问题 What is the code for determining if a user is in a role? I have set up all the users through the ASP.NET Configuration Security tab but now want to put logic around some key areas so only people in certain roles can see and access these areas. 回答1: if (User.IsInRole("rolename")) { // my action } 回答2: Easy~ HttpContext.Current.User.IsInRole("roleName") 回答3: Check out the Roles class, specifically IsUserInRole, GetUsersInRole, AddUserToRole, etc. I use these all the time. 回答4: thanks to "Chris

Can we personalize Session Timeout for Roles in ASP.NET MVC 5

丶灬走出姿态 提交于 2019-12-18 05:00:33
问题 The idea is to set different values of Session Timeout for different User Roles in ASP.NET MVC 5 and ASP.NET Identity. Is it possible to do? 回答1: Based on their role you could set the timeout, i.e. HttpContext.Current.Session.Timeout = 20; Going by your previous question you want to do this dynamically. You could store and update the times themselves in session and set for each role on OnActionExecuting of a base controller. if (User.IsInRole("Admin")) { filterContext.HttpContext.Session

Wordpress Role Display Name

守給你的承諾、 提交于 2019-12-18 04:57:12
问题 I am looking for a neat way to get the Wordpress role display name. When you add the role (e.g. add_role( 'special', 'A Special Role'); ), you get to set a display name. When you get the role (e.g. get_role( 'special' ); ) the role object returned simply has the name and the capabilities object. WP_Role Object( [name] => special [capabilities] => Array() ) And no display name. The display name is used all over the WP Admin back-end (users.php and user-edit.php), but it's a rabbit warren ...

ASP.NET MVC - Dynamic Authorization

点点圈 提交于 2019-12-17 22:26:17
问题 I am building a simple CMS in which roles are set dynamically in the admin panel. The existing way of authorizing a controller method, adding [Authorize(Roles="admin")] for example, is therefore no longer sufficient. The role-action relationship must be stored in the database, so that end users can easily give/take permissions to/from others in the admin panel. How can I implement this? 回答1: If you want to take control of the authorization process, you should subclass AuthorizeAttribute and

dynamic roles on a Java EE server

不打扰是莪最后的温柔 提交于 2019-12-17 16:27:49
问题 I want to manage user and roles in a dedicated application. For example a user of this application ("customerX boss") can create a new role "customerX employee". If an employee accesses the Java EE application server (GlassFish 3) he should get the role "customerX employee". It sounds simple, but it is not supported by Java EE, because groups are mapped to roles at start-up time and the roles within the application are static. What is the best way to manage user roles at runtime in a Java EE

Grant all on a specific schema in the db to a group role in PostgreSQL

为君一笑 提交于 2019-12-17 04:15:40
问题 Using PostgreSQL 9.0, I have a group role called "staff" and would like to grant all (or certain) privileges to this role on tables in a particular schema. None of the following work GRANT ALL ON SCHEMA foo TO staff; GRANT ALL ON DATABASE mydb TO staff; Members of "staff" are still unable to SELECT or UPDATE on the individual tables in the schema "foo" or (in the case of the second command) to any table in the database unless I grant all on that specific table. What can I do make my and my

Drop a role with privileges

我是研究僧i 提交于 2019-12-14 03:59:39
问题 This looks like a very basic need, but I do not find any quick and suitable answer. I have a role in Postgres which has privileges to many other tables in various databases. I need to drop this role. I have one postgres instance and then many databases on top of it. SELECT DISTINCT 'REVOKE ALL ON TABLE ' || table_schema || '.' || table_name || ' FROM ' || r.param_role_name || ';' FROM information_schema.table_privileges CROSS JOIN (SELECT 'some_role_name'::text AS param_role_name) r WHERE

AddToRole() method doesn't result in db entry in ASP.NET Identity

两盒软妹~` 提交于 2019-12-14 01:26:42
问题 I'm using ASP.NET Identity in my ASP.NET MVC app. My problem occures while adding user to role. There isn't any exception, but as a result of um.AddToRole() no db entry is added to AspNetUserRoles table. My action method looks like that: public ActionResult GrantAdmin(string id) { ApplicationUser user = um.FindById(id); if (!rm.RoleExists("admin")) { rm.Create(new IdentityRole("admin")); } um.AddToRole(user.Id, "admin"); return View((object)user.UserName); } um is an object of UserManager

How can I enable components/actions based on role?

我的梦境 提交于 2019-12-13 16:49:44
问题 I'm currently making a frontend app for a project using angular 4, from the backend I get some actions called with a POST that are the same: actions.response.ts export class actions{ AGREEMENTS_VIEW :string; PROSPECTS_VIEW :string; AGREEMENTS_INSERT_UPDATE :string; PRODUCTS_INSERT_UPDATE :string; PROSPECTS_INSERT_UPDATE :string; DOCUMENTS_VIEW :string; DOCUMENTS_INSERT_UPDATE :string; } Now, what I want to do: Based on each actions (agreements_view, prospects_view.. etc) i want to enable or

how to make masterPage contents visible based on role?

吃可爱长大的小学妹 提交于 2019-12-13 16:06:12
问题 I am developing an application with masterPage. I want to put loginStatus, LoginName controls into masterPage. now, I want these loginStatus and LoginName controls be visible only if the user is admin. (admin will exclusively navigate to login page and no Login/logout link, logged in username should be shown for non-admins) how can I achieve this? 回答1: There is a LoginView, which supports roles: <asp:LoginView ID="LoginView1" runat="server"> <RoleGroups> <asp:RoleGroup Roles="Admin"> </asp