在web.config中:
復制代碼 代碼如下:
<connectionStrings>
<add name="SqlServices" connectionString="server=.;database=data;uid=sa;pwd=123;" />
</connectionStrings>
復制代碼 代碼如下:
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="SqlServices"
applicationName="dev"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
passwordFormat="Hashed"
minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0"
/>
</providers>
</membership>
重設密碼關鍵語句:復制代碼 代碼如下:
MembershipUser mem = Membership.GetUser(this.lblUserName.Text);
string p = mem.ResetPassword();
mem.ChangePassword(p, "123456");