管理员更改密码 [英] Admin change password

查看:60
本文介绍了管理员更改密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使管理员能够在用户忘记其对安全性问题的答案时更改密码.但是我无法使它正常工作.用户名是登录名.这是我的代码:


I am try to enable admins a way to change passwords for when a user forgets their answer to the security question. But I can not get it to work. Username is login name. Here is my code:


Protected Sub btnResetPasswordClick(sender As Object, e As EventArgs)
       Dim userName As Label = Me.FormViewUserAccess.FindControl("UserNameLabel")
      
       Dim mp As MembershipProvider = Membership.Providers("AspNetAdminMembership")
       Dim user As MembershipUser = mp.GetUser(userName, False)
       Dim pass As String = user.ResetPassword
       Dim mm As New System.Net.Mail.MailMessage("mysite.com", user.Email)
       mm.Subject = "My Website"
       mm.Body = "Your password has been changed to: " & vbCrLf & pass & vbCrLf & _
           "Please login and change your password" & vbCrLf & _
            " SYSTEM GENERATED EMAIL - DO NOT RESPOND"

       Dim client As New SmtpClient
       Try
           client.Send(mm)
       Catch ex As Exception

       End Try
End Sub




这是我的webconfig中的内容:




Here is what I have in my webconfig:

<membership>
    <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
        <add name="AspNetAdminMembership" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
    </providers>
</membership>



有人可以指出我要去哪里了,我是asp.net的新手,但出现以下错误:提供的提供者用户密钥无效.它必须是System.Guid类型.
参数名称:providerUserKey



Can someone point out where I am going wrong, I am new to asp.net and I get the following error: The provider user key supplied is invalid. It must be of type System.Guid.
Parameter name: providerUserKey

推荐答案



检查是否可行.

http://forums.asp.net/t/1077393.aspx/1 [ ^ ]
Hi,

Check if this works.

http://forums.asp.net/t/1077393.aspx/1[^]


这篇关于管理员更改密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆