System.Web.Security.MembershipProvider.GetPassword Method

Gets the password for the specified user name from the data source.

Syntax

public abstract string GetPassword (string name, string answer)

Parameters

name
Documentation for this section has not yet been entered.
answer
The password answer for the user.

Returns

The password for the specified user name.

Remarks

Takes, as input, a user name and a password answer and retrieves the password for that user from the data source and returns the password as a string.

The MembershipProvider.GetPassword(string, string) method ensures that the MembershipProvider.EnablePasswordRetrieval flag is set to true before performing any action. If MembershipProvider.EnablePasswordRetrieval is false, a NotSupportedException exception is thrown.

MembershipProvider.GetPassword(string, string) also checks the value of the MembershipProvider.RequiresQuestionAndAnswer property. If MembershipProvider.RequiresQuestionAndAnswer is true, MembershipProvider.GetPassword(string, string) checks the value of the supplied answer parameter against the stored password answer in the data source. If they do not match, a System.Web.Security.MembershipPasswordException exception is thrown.

If your custom membership provider supports hashed passwords, the MembershipProvider.GetPassword(string, string) method should throw an exception if the MembershipProvider.EnablePasswordRetrieval property is set to true and the password format is set to Hashed. Hashed passwords cannot be retrieved.

Requirements

Namespace: System.Web.Security
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0