System.Web.Security.MembershipUser.GetPassword Method

Gets the password for the membership user from the membership data store.

Syntax

public virtual string GetPassword (string answer)

Parameters

answer
Documentation for this section has not yet been entered.

Returns

The password for the membership user.

Remarks

MembershipUser.GetPassword(string) calls the MembershipProvider.GetPassword(string, string) method of the membership provider referenced by the MembershipUser.ProviderName property to retrieve the password for the membership user from the membership data store. If a password answer is required and an incorrect password answer is supplied, a System.Web.Security.MembershipPasswordException is thrown by the membership provider.

If Membership.EnablePasswordRetrieval is false, the membership provider will return an exception. If the provider supports passwords with a SqlMembershipProvider.PasswordFormat of MembershipPasswordFormat.Hashed, you will be unable to retrieve the password for the membership user and should consider making use of the MembershipUser.ResetPassword method when a user has forgotten his or her password.

Note:

A System.Configuration.ConfigurationException will be thrown if enablePasswordRetrieval is set to true and passwordFormat is set to Hashed in the Web.config file for the ASP.NET application.

If Membership.RequiresQuestionAndAnswer is false, you can supply null for the answer parameter, or use the MembershipUser.GetPassword overload that does not take any parameters.

Requirements

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