membership-provider

How do I manually set a user's role in ASP.NET MVC?

喜夏-厌秋 提交于 2019-12-21 07:26:06
问题 This project I'm working on requires me to keep a local db of admin users and use an external db for regular users. Anyone who passes authentication in the admin db should be assigned the 'admin' role, and anyone authenticated through the other db will always be assigned a 'user' role. Can I manually assign these roles? I don't need the complexity of a Role Provider or anything, since I'm only using these two roles which will ALWAYS be based on which db they authenticate with. It would be a

How do I manually set a user's role in ASP.NET MVC?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 07:26:04
问题 This project I'm working on requires me to keep a local db of admin users and use an external db for regular users. Anyone who passes authentication in the admin db should be assigned the 'admin' role, and anyone authenticated through the other db will always be assigned a 'user' role. Can I manually assign these roles? I don't need the complexity of a Role Provider or anything, since I'm only using these two roles which will ALWAYS be based on which db they authenticate with. It would be a

Extend Membership API, MembershipUser

折月煮酒 提交于 2019-12-21 05:49:23
问题 I created my own database schema to store user information. CREATE TABLE [dbo].[MyCustomMembership_Users]( [UserId] [uniqueidentifier] NOT NULL, [UserName] [nvarchar](256) NOT NULL, [LoweredUserName] [nvarchar](256) NOT NULL, [MobileAlias] [nvarchar](16) NULL, [IsAnonymous] [bit] NOT NULL, [LastActivityDate] [datetime] NOT NULL, [FirstName] [nvarchar](256) NULL, [MiddleName] [nvarchar](256) NULL, [LastName] [nvarchar](256) NULL) Then I extend the MembershipProvider and MembershipUser and

ASP.NET simple membership provider?

无人久伴 提交于 2019-12-20 11:36:09
问题 I opened Asp.Net Mvc 4 Internet App. template. And I set connection string for my database like this: <connectionStrings> <add name="DefaultConnection" connectionString="Data Source=ALI-PC\;Initial Catalog=OsosPlusDb;Persist Security Info=True;User ID=sa;Password=sa;" providerName="System.Data.SqlClient" /> </connectionStrings> I run project, click register button. I created a new user like this: When I click register to post I get this error: But it creates a new user in DB and it does not

A Custom Membership Provider *Without* a Database?

落花浮王杯 提交于 2019-12-20 06:07:11
问题 I've been looking around various SO questions, blog posts, and so forth regarding the changes to membership providers in MVC 4. While I like many of the changes and the simplification of things (particularly the out-of-the-box external login support), I'm as yet unable to find one seemingly-simple thing... How can I override the membership/role provider with a custom one that uses another data source? I don't want to replace WebSecurity or anything that drastic, since it handles all of the

ASP.NET Membership Issues With Registration

丶灬走出姿态 提交于 2019-12-20 05:47:34
问题 I'm having a rough time with this membership stuff. OK, so, it's really odd. I can register a user. I can register, I can login. However, when I go to register ANOTHER user the user isn't saved in the database and I get a Membership credential verification failed event when the user tries to login (I assume because the user is never being saved). Here is the code I am using to save a new user. On the page: protected void btnRegister_Click(object sender, EventArgs e) { if (false ==

How do you change a hashed password using asp.net membership provider if you don't know the current password?

烂漫一生 提交于 2019-12-17 17:29:30
问题 Problem, there's no method: bool ChangePassword(string newPassword); You have to know the current password (which is probably hashed and forgotten). 回答1: This is an easy one that I wasted too much time on. Hopefully this post saves someone else the pain of slapping their forehead as hard as I did. Solution, reset the password randomly and pass that into the change method. MembershipUser u = Membership.GetUser(); u.ChangePassword(u.ResetPassword(), "myAwesomePassword"); 回答2: You are not able

How do I use my own database with SimpleMembership and WebSecurity? What is MVC4 security all about?

南笙酒味 提交于 2019-12-17 06:21:43
问题 I've read everything on this topic I could find, including MSDN articles and SO posts, but I'm still very lost and confused. Questions Please answer the following (briefly, if possible): What is SimpleMembership/SimpleMembershipProvider ( WebMatrix.WebData ) and what is it/are they responsible for? What is WebSecurity ( WebMatrix.WebData )? What is the Membership ( System.Web.Security ) class? Why does MVC4 create a UserProfile table and a webpages_Membership table? What are they for and what

Anti forgery token is meant for user “” but the current user is “username”

萝らか妹 提交于 2019-12-17 04:11:13
问题 I'm building a single page application and experiencing an issue with anti-forgery tokens. I know why the issue happens I just don't know how to fix it. I get the error when the following happens: Non-logged-in user loads a dialog (with a generated anti-forgery token) User closes dialog User logs in User opens the same dialog User submits form in dialog Anti forgery token is meant for user "" but the current user is "username" The reason this happens is because my application is 100% single

Simple Membership Provider vs Universal vs Code-First

 ̄綄美尐妖づ 提交于 2019-12-14 03:49:44
问题 I would like to ask what is difference betweeen this three membership providers from SQL Server Compact perspective. As far I as I saw first two of them can use compact server by design and third one by coincidence I guess, because of entity framework. So, is there any difference in fact? 回答1: Difference is Universal is nearly the same as original with added support for SQL Compact and Azure. Simple membership is a bit simplified, has a few additional modern implementations like token based