15 November 2010

FBA : Change Password

From my Earlier blog stating Form Based Authentication in SharePoint (MOSS 2007).
 ( Click Here )

Many were interested in password management for the users. A complete package ready to use is uploaded on codeplex.
However here I’m attaching a custom strip down to users change Password code snippet for the same.

There are two options while password management
1. Just to change Password
2. to provide Question & Answer along with Password change
Note : for Option (2) please add/updated web.Config file within Membership provider

///save button functionlity
void btnChangePassword_Click(object sender, EventArgs e)
if (Validate(true))
string AppName = Membership.ApplicationName;
if (.Text.Trim().ToString() != .Text.Trim().ToString())
{ .Text = " New and Confirm password Mismatch ! " ; }
if (Membership.Provider.ChangePassword(.Text, .Text, .Text))
{ //membership provider has Change Password checked in Web.Config
if (Membership.Provider.ChangePasswordQuestionAndAnswer(.Text, .Text, .Text, .Text))
//Message: " Your Password Has Been Sucessfully Changed.."
catch (MembershipPasswordException ee)
{//Exception Message}


Let me know your comments/ exceptions etc.
Will be glad to get back to you.

No comments:

Post a Comment

Thanks for your valuable comments

Rate Now: