How reset password if not know old one

C

Cirene

Using ASP.NET built in membership.

I'm creating an "admin interface" to my site.

Thru code, how can I reset someones password without knowing the old/current
one?
 
J

Joe Fawcett

Cirene said:
Using ASP.NET built in membership.

I'm creating an "admin interface" to my site.

Thru code, how can I reset someones password without knowing the
old/current one?
You don't need to know the old password if you use the Reset password
method, that takes the username and the security question answer.
Otherwise provide your own MembershipProvider implementation. Just inherit
from the standard one and add your own method, ChangePassword, that does
what you need.
 
S

Stan

Using ASP.NET built in membership.

I'm creating an "admin interface" to my site.

Thru code, how can I reset someones password without knowing the old/current
one?

You can do it with the default membership provider.

There are a number of settings in web.config that will affect the
password regime (see example below). If EnablePasswordReset is false
then the system will demand the old password or the security question
answer. Otherwise the ResetPassword() method can have no parameters
although it will supply an automatically generated new password that
you cannot choose.

If you wan't to set the password to something specific then it
requires two steps:

string AutoPassword= AMembershipUser.ResetPassword();
AmembershipUser.ChangePassword(AutoPassword, "MyPreferredPassword")

HTH

Appendix:

Extract from web.config where the ASP.NET tab in IIS manager dialog
has been used to override default settings:

<membership>
<providers>
<remove name="AspNetSqlMembershipProvider" />
<add connectionStringName="LocalSqlServer"
enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="true"
applicationName="/" requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>
 
C

Cirene

Thanks so much!

Stan said:
You can do it with the default membership provider.

There are a number of settings in web.config that will affect the
password regime (see example below). If EnablePasswordReset is false
then the system will demand the old password or the security question
answer. Otherwise the ResetPassword() method can have no parameters
although it will supply an automatically generated new password that
you cannot choose.

If you wan't to set the password to something specific then it
requires two steps:

string AutoPassword= AMembershipUser.ResetPassword();
AmembershipUser.ChangePassword(AutoPassword, "MyPreferredPassword")

HTH

Appendix:

Extract from web.config where the ASP.NET tab in IIS manager dialog
has been used to override default settings:

<membership>
<providers>
<remove name="AspNetSqlMembershipProvider" />
<add connectionStringName="LocalSqlServer"
enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="true"
applicationName="/" requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top