MSDN Library

WebSecurity.ChangePassword Method

Changes the password for the specified user.

Namespace:  WebMatrix.WebData
Assembly:  WebMatrix.WebData (in WebMatrix.WebData.dll)

'Declaration
Public Shared Function ChangePassword ( _
	userName As String, _
	currentPassword As String, _
	newPassword As String _
) As Boolean
'Usage
Dim userName As String
Dim currentPassword As String
Dim newPassword As String
Dim returnValue As Boolean

returnValue = WebSecurity.ChangePassword(userName, _
	currentPassword, newPassword)

Parameters

userName
Type: System.String
The user name.
currentPassword
Type: System.String
The current password for the user.
newPassword
Type: System.String
The new password.

Return Value

Type: System.Boolean
true if the password is successfully changed; otherwise, false.

ExceptionCondition
InvalidOperationException

The SimpleMembershipProvider.Initialize(String, NameValueCollection) method was not called.

-or-

The InitializeDatabaseConnection method was not called.

-or-

The SimpleMembershipProvider membership provider is not registered in the configuration of your site. For more information, contact your site's system administrator.

For an example of how to use the ChangePassword(String, String, String) method, see the ChangePassword.cshtml file in the Starter Site template.

  • Medium trust for the immediate caller. This member can be used by partially trusted code.
Show:
© 2016 Microsoft