roleprovider

What could cause many data access exceptions using EF code first in a custom RoleProvider?

人盡茶涼 提交于 2019-12-18 09:27:15
问题 My role provider looks like the class below (abridged). I am running on IIS Express, and SQL 2012 Express, from VS 2012, and I get a multitude of seemingly random exceptions in this role provider code. public class Educ8RoleProvider : RoleProvider { private readonly Educ8DbContext _dbContext = new Educ8DbContext(); private readonly Authorization _authorization; public Educ8RoleProvider() { _authorization = new Authorization(_dbContext); } public override void Initialize(string name, System

How to use a MVC WebAPI OData endpoint securely?

≡放荡痞女 提交于 2019-12-18 09:23:25
问题 I have an OData endpoint defined at ~/odata/ , which doesn't need to be accessed unless a user has been authenticated (in fact, how would you secure this for non-authenticated users). I setup role-based authentication to this path in the web.config with: <location path="odata"> <system.web> <authorization> <allow roles="WaitConfirmation, etc...."/> </authorization> </system.web> </location> When a user logs in, I don't use the OData endpoint for authentication (primarily because I need to

is there an authorizeattribute equivalent to just standard web forms (not MVC) for .net

别来无恙 提交于 2019-12-17 14:50:35
问题 I'm working on a project that will use windows role providers and I want to limit functionality to certain AD groups. With MVC, I could use an AuthorizeAttribute above my action methods and redirect accordingly. Is there something similar I can do for a standard web forms application (.NET 3.5) that doesn't use MVC? 回答1: You can set this up in web.config with the authorization element. <configuration> <system.web> <authorization> <allow roles="domainname\Managers" /> <deny users="*" /> <

ASP .NET Custom RoleProvider not respecting cacheRolesInCookie=“true”

浪子不回头ぞ 提交于 2019-12-17 07:50:37
问题 I've implemented a custom role provider, and configured it in my web.config file like this: <roleManager enabled="true" defaultProvider="TDRoleProvider" cacheRolesInCookie="true"> <providers> <clear/> <add name="TDRoleProvider" type="TDRoleProvider"/> </providers> </roleManager> I've overridden the GetRolesForUser function in my custom role provider, and I've stepped into it, and it works just fine - loads up 60 roles for the user I'm testing with. However, I've noticed that the

ASP .NET Custom RoleProvider not respecting cacheRolesInCookie=“true”

冷暖自知 提交于 2019-12-17 07:49:29
问题 I've implemented a custom role provider, and configured it in my web.config file like this: <roleManager enabled="true" defaultProvider="TDRoleProvider" cacheRolesInCookie="true"> <providers> <clear/> <add name="TDRoleProvider" type="TDRoleProvider"/> </providers> </roleManager> I've overridden the GetRolesForUser function in my custom role provider, and I've stepped into it, and it works just fine - loads up 60 roles for the user I'm testing with. However, I've noticed that the

Turning off only the Role Provider in SimpleMembership

佐手、 提交于 2019-12-14 02:23:41
问题 I have read a ton of different posts and tutorials and couldn't find an answer to this specific need. I'd like to use the SimpleMembership provider in my ASP.NET MVC app, but I would like to turn the Role provider off (OAuth too since I will not be using it). That means that I would like the SMP to create only webpages_Membership table on initialization, not the tables for oauth or roles. Note that I don't want to turn off the SimpleMembership, only the roles and the oauth support. Question:

Why would this catch all block not in fact catch all

邮差的信 提交于 2019-12-12 08:47:16
问题 The code is fairly simple --- the issue is that there is an invalid character in the groupPath string (a '/' to be exact). What I'm trying to do (at least as a stop gap) is skip over DirectoryEntries that I can't get the cn for --- regardless of why. However when I run this code the catch block doesn't run and I get instead: The server is not operational. and an unhandled System.Runtime.InteropServices.COMException. Why would the catch block not catch this exception. try { using

sample c# code to manage roles with roles provider

断了今生、忘了曾经 提交于 2019-12-12 01:33:58
问题 i want to implement asp.net role provider to assign users over my LAN to roles and have my asp.net intranet app implement security based on roles. i dont want to use VS to manage this with the built in tools but rather hand this off to users to manage themselves. i want an admin folder with a page(s) for admin roles to be able to create/edit roles and manage users in roles... this way an admin can add a domain user (MyDomain\Username) to a role such as ProojectManager or Tester or Developer..

ASP.NET web forms - how to combine WIF authentification with membership provider and role provider

放肆的年华 提交于 2019-12-12 01:08:29
问题 I'm using windows identity foundation with form authentification in ASP.NET Web Forms in .NET 4.5 How can I combine WIF form authentification with my custom membership provider and my custom role provider defined in web.config? I want to use my custom membership provider for load additional user info from SQL DB such as email, birthday, avatar iamge. I want to use my custom role provider to obtain all roles from SQL DB for authentificated user. My authentification method Authenticate(userName

Adding more than one role to a user after registring in asp.net

♀尐吖头ヾ 提交于 2019-12-11 08:51:29
问题 in my web site, i have three roles(Editor , Reviewer and Author) In some situations I need to add my user all 3 roles by coding. how can i do that? an also how can i update my user roles? thank you very much please guide me. MembershipUser user = Membership.CreateUser(email, "123456",email); Roles.AddUserToRole(email, "Editor"); 回答1: To add user to multiple roles use Roles.AddUserToRoles like this Roles.AddUserToRoles(email, new string[] {"Editor", "Reviewer", "Author" }); I do not know about