asp.net-membership

Wrapping membership provider and dbcontext on single transaction

血红的双手。 提交于 2019-12-07 07:51:41
问题 MVC Project using EF 5 code first and .NET 4.5. I was looking for a way to wrap dbContext and SimpleMembershipProvider on a single transaction. I tried to use TransactionScope but since the membership provider will open another connection I get an exception (MSDTC on server 'servername' is unavailable). So I though I could use ObjectContext.Connection.BeginTransaction instead. The membership provider won't be part of the transaction but the idea is to have it somewhere where if it fails the

SQL aspnet_profile

*爱你&永不变心* 提交于 2019-12-07 05:45:16
问题 any idea how I can get user FirstName and LastName from the aspnet_profile table based on UserID using SQL becasue I would like to use in Telerik Reporting as a user parameter. Sample row (FirstName is George, LastName is Test): UserID: 06b24b5c-9aa1-426e-b7e4-0771c5f85e85 PropertyName: MobilePhone:S:0:0:Initials:S:0:1:City:S:1:14:FirstName:S:15:6:PostalCode:S:21:7:‌​WorkPhone:S:28:12:LastName:S:40:5:Address1:S:45:17:Address2:S:62:0:Province:S:62:‌​2:Organization:S:64:4:ClinicId:S:68:1

MemberShipException during the User Register at ASP.NET

£可爱£侵袭症+ 提交于 2019-12-07 04:40:32
I'm using the ASP.NET MVC 4 template to create my application, in my method Register POST, i put a block that call the UserProfile and save new information, on this case, it will save UserType . The problem is: Every time that I'll save the user, the exception MembershipCreateUserException is called and the following message is displayed on the page: User name already exists. Please enter a different user name. The User is saved on Database. This is my method Register: public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user try { // var

Thread.CurrentPrincipal set in Application_AuthenticationRequest is not set later in the app

≡放荡痞女 提交于 2019-12-07 03:27:13
问题 In the global.asax file for the Application_AuthenticationRequest I'm setting the Thread.CurrentPrincipal to a custom principal. I also set the HttpContext.Current.User to the same principal. However later in the app when I need to cast the Thread.CurrentPrincipal to our custom type, I get a runtime error saying: Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'OurCustomPrincipal'. How did the Thread.CurrentPrincipal get reset to RolePrincipal, and more to the point

How to Display Validation Error Messages on an ASP.NET MVC Page?

て烟熏妆下的殇ゞ 提交于 2019-12-07 03:09:36
问题 I am pretty new to ASP.NET and C# I have spent the day learning the basics of the ASP.NET Membership provider I have built all my validator but are getting stuck at outputting my error message on the page. private void LogCreateUserError(MembershipCreateStatus status, string username) { string reasonText = status.ToString(); switch (status) { case MembershipCreateStatus.DuplicateEmail: case MembershipCreateStatus.DuplicateProviderUserKey: case MembershipCreateStatus.DuplicateUserName:

C# MembershipUser.ChangePassword fails for one user only?

被刻印的时光 ゝ 提交于 2019-12-06 17:45:29
I'm using the change password feature of the standard AspNetSqlMembershipProvider in my ASP.NET MVC-2 app: MembershipUser user = Membership.GetUser(userId); string pwd = user.ResetPassword(); if (user.ChangePassword(pwd, confirmPassword)) { // it worked } And this works for the vast majority of users, but there are a couple of users that can not change their passwords - user.ChangePassword() just returns false. I've tried it myself to see what was going on, and entered a simple password 12345678 for that user and it failed to change. So it's not because they are entering passwords that do not

How to use ActiveDirectoryMembershipProvider with ASP.Net Identity?

怎甘沉沦 提交于 2019-12-06 17:04:23
问题 I am trying to learn how to use ASP.Net Identity. My scenario is that I have to authenticate against Active Directory. For that purpose I am trying to use ActiveDirecotoryMembershipProvider . What I have to do is - Authenticate user/password against Active Directory. Check whether user is present in my own database. The way I did it is I configured in my web.config to use ActiveDirectoryMembershipProvider as default membership provider. Then I override PasswordSignInAsync method in my

Disabling account lockout with the SqlMembershipProvider

心不动则不痛 提交于 2019-12-06 16:39:27
问题 How do I disable the account lockout feature of the SqlMembershipProvider ? The MSDN documentation for the MaxInvalidPasswordAttempts property does not specify how to disable it. If I can't find the correct way to do it I will set the maxInvalidPasswordAttempts attribute to the maximum value of an int which may effectively achieve the same result. I'm well aware that disabling account lockout isn't the greatest idea but I need to achieve this in the short term. 回答1: Setting the

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

Automatically sign out from Forms Authentication in ASP.NET when browser is closed

眉间皱痕 提交于 2019-12-06 15:52:17
问题 Is there a way to force ASP.NET to sign out from it's authentication when the browser is closed or the user types in a new address? If the browser is left open then I need to keep the user authenticated, so a long timeout on the authentication ticket is preferable. 回答1: Not sure if this is still an issue but this resolved the issue for me. Just add the following to the Page_Load event of your Start Page: protected void Page_Load(object sender, EventArgs e) { if (Request.UrlReferrer == null ||