roleprovider

Accessing authorization information in web.config

无人久伴 提交于 2019-12-07 09:24:52
问题 I'm writing a custom role provider and I need programmatic access the authorization information stored in the web.config. Certain section of the site are only accessible by certain roles. I would like to find out which roles can access a page and/or which page a certain role can access. I can't seem to figure this one out. 回答1: You can access any information stored such as ConnectionStrings,AppSettings and other defined values in web.config by WebConfigurationManager class in System.Web

ASP.NET Role Provider vs Membership Provider

早过忘川 提交于 2019-12-06 16:47:21
Please refer to this post. I have become able to configure my web.config file so that when an unauthenticated user requests a page, he is redirected to the Login.aspx page. I have been able to do that by configuring web.config file and the following few lines of code: protected void btnLogin_Click(object sender, EventArgs e) { string username = this.usernameTextBox.Text; string password = this.passwordTextBox.Text; bool success = Membership.ValidateUser(username.Trim(), password.Trim()); if (success) { FormsAuthentication.SetAuthCookie(username, true); Ice_Web_Portal.BO.User user = Ice_Web

Extending the RoleProvider GetRolesForUser()

北城以北 提交于 2019-12-06 15:52:45
The GetRolesForUser() method in the RoleProvider takes the user login name and returns the list of roles for that user. But in my application this is not enough, I need a few more pieces of information to be able to get the user's roles. How can I get this extra information into the method? I have it in the Session , but I found out that Session is not available in the RoleProvider . What I had in mind was putting this extra info in some class that extends MembershipUser , assuming I can get to it inside the RoleProvider . But I don't know how to create the CustomMembershipUser and make it

ASP.NET Universal Providers - Roleprovider does not cache roles in cookie

别说谁变了你拦得住时间么 提交于 2019-12-06 08:22:16
问题 Ironically my role provider does not cache the roles in a cookie anymore. That was working earlier. Unfortunately i have noticed that only now, so i cannot say what causes the problem. But i think it has to do with the update to the new version 1.2 of the universal providers (released on 16th august). My config for the roleprovider looks like: <roleManager enabled="true" cacheRolesInCookie="true" cookieName="X_Roles" cookiePath="/" cookieProtection="All" cookieRequireSSL="true"

Symfony2 in_memory users provider issue

試著忘記壹切 提交于 2019-12-06 03:52:30
问题 I have a Symfony2 application that loads users from in_memory user provider. The security.yml is the following: security: encoders: Symfony\Component\Security\Core\User\User: plaintext role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] providers: in_memory: users: admin: { password: mypassword, roles: [ 'ROLE_ADMIN' ] } firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false login: pattern: ^/demo/secured/login$ security

Refresh ASP.NET Role Provider

≯℡__Kan透↙ 提交于 2019-12-06 02:56:22
simple question... Given I have an ASP.NET site, which uses a [custom] RoleProvider, Is there any way in which I can somehow "refresh" the provider without forcing the user to log out of the site and log back in? I'm looking for something that would be akin to a fictional method Roles.Refresh() Specifically, I am looking at this for if an administrator changes a user's roles, the user sessions could maybe refresh themselves every 10 minutes or something. I assume you have something like this in your web.config : <roleManager enabled="true" defaultProvider="..." cacheRolesInCookie="true"> The

attribute for .net MVC controller action method

核能气质少年 提交于 2019-12-05 22:12:13
问题 Essentially I want to show a friendly message when someone is not part of a role listed in my attribute. Currently my application just spits the user back to the log in screen. I've read a few posts that talk about creating a custom attribute that just extends [AuthorizeAttribute], but I'm thinking there's got to be something out of the box to do this? can someone please point me in the right direction of where I need to look to not have it send the user to the log in form, but rather just

Accessing authorization information in web.config

允我心安 提交于 2019-12-05 19:07:12
I'm writing a custom role provider and I need programmatic access the authorization information stored in the web.config. Certain section of the site are only accessible by certain roles. I would like to find out which roles can access a page and/or which page a certain role can access. I can't seem to figure this one out. You can access any information stored such as ConnectionStrings,AppSettings and other defined values in web.config by WebConfigurationManager class in System.Web.Security namespace. Let's say you have defined and authorization section as: <system.web> <authorization> <allow

Reference current RoleProvider instance?

安稳与你 提交于 2019-12-04 22:34:51
When inside an ASP.NET page, module or handler with an HttpContext present, how do I get a reference to the current RoleProvider instance? It's the provider used for authorization when the IPrincipal.IsInRole(..) method is called. By default, or from configuration, my provider seems to be a SqlRoleProvider instance by an error given when I'm running the app. I want to inspect the type of provider at runtime to provide feedback on which one is actually being used. The static Roles class has a Provider property on it which you can use to reference the current provider. Roles.Provider and if you

ASP.NET Universal Providers - Roleprovider does not cache roles in cookie

落花浮王杯 提交于 2019-12-04 15:09:04
Ironically my role provider does not cache the roles in a cookie anymore. That was working earlier. Unfortunately i have noticed that only now, so i cannot say what causes the problem. But i think it has to do with the update to the new version 1.2 of the universal providers (released on 16th august). My config for the roleprovider looks like: <roleManager enabled="true" cacheRolesInCookie="true" cookieName="X_Roles" cookiePath="/" cookieProtection="All" cookieRequireSSL="true" cookieSlidingExpiration="true" cookieTimeout="1440" createPersistentCookie="false" domain="" maxCachedResults="25"