Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Password Policy in ASP.NET Profile (Membership)

In change password page, we have this code, So if we want to change Password Policy into "StrongPolicy", have we a way or is it by default?

Also can we change it to weak policy ?

I read MSDN but couldn't find it.

Membership mu ; 
mu=Membership.GetUser(txtUserName.Text); 

mu.UnlockUser();
var newPass= mu.ResetPassword();
mu.ChangePassword(newPass,TxtPassword.Text);
like image 378
Ali Sarshogh Avatar asked Dec 15 '22 05:12

Ali Sarshogh


1 Answers

If you are using MVC 5 (possibly MVC4, havent checked).

Theres a nice easy way of changing this without changing the config. In your solution explorer, go to

'App_Start' > IdentityConfig

Here you will see a passwordvalidator, changing these settings will allow you to alter the complexity of passwords required for your site:

manager.PasswordValidator = new PasswordValidator { RequiredLength = 6, RequireNonLetterOrDigit = true, RequireDigit = true, RequireLowercase = true, RequireUppercase = true, };

like image 166
Jay Avatar answered Dec 29 '22 16:12

Jay