Click here to Skip to main content
15,861,168 members
Articles / Web Development / HTML
Article

MOSS Change Password Feature for FBA

Rate me:
Please Sign up or sign in to vote.
4.94/5 (11 votes)
28 Dec 2008CPOL3 min read 99.3K   597   14   29
This feature enables a MOSS user to change his/her password when forms based authentication is enabled

Introduction

This article explains how to make a change password feature in MOSS 2007, so the user can change his/her password. This article doesn't describe how to enable FBA (Forms Based Authentication) in MOSS that you can find easily in different blogs and articles in the internet. I suggest this article on The Code Project: MOSS 2007 – Enabling Forms Authentication [^].

Problem

When you enable forms authentication on MOSS, it means that users credentials are stored in membership database like ASP.NET database. MOSS doesn't facilitate the user to change his/her password in this database.

Solution

Our suggested solution is adding a new feature (Change Password feature) in the standard user menu:

Image 1

The feature redirects the user to a custom page (ChangePassword.aspx) that prompts him to enter current and new passwords.

Image 2

Solution Details

If you are not interested to walk through the solution, you can use the attached files and go directly to Part III Deployment. Actually I got the solution from Sheetal Jain's blog [^] but I added details and clarifications.

The following steps explain the solution in detail:

  1. Creating ChangePassword.aspx 
  2. Creating ChangePassword feature 
  3. Deployment

1. Creating ChangePassword.aspx

You can do it using Visual Studio by creating a new web site ‘TempSite’ and then:

  1. Adding a new web form ‘ChangePassword.aspx

  2. Dragging a ChangePassword control form the toolbox to the form

  3. Setting control effective properties like (NewPasswordRegularExpressionErrorMessage, CancelDestinationPageUrl, ContinueDestinationPageUrl)

  4. Applying MOSS master page, by setting ‘MasterPageFile’ page property to your selected master page in MOSS like ‘~/_layouts/simple.master’, then removing all HTML tags and adding content tag for the master page content place holder (PlaceHolderMain for the main content in the middle of the page). The final page should be like this page:

    ASP.NET
    <%@ Page Language="C#" MasterPageFile="~/_layouts/simple.master"  %>
    
    <asp:Content ID="Content1" ContentPlaceHolderId="PlaceHolderMain" runat="server">
    <asp:ChangePassword id="myChangePassword" 
    	newpasswordregularexpressionerrormessage="Error: 
    	Your password must be at least 7 characters long, 
    	and contain at least one number and one special character."
    runat ="server" CancelDestinationPageUrl="~/pages/default.aspx"
    ContinueDestinationPageUrl="~/pages/default.aspx" >
    </asp:ChangePassword>
    
    </asp:Content>

2. Creating ChangePassword Feature

Before you start, here is a good tutorial for creating custom features in MOSS [^]:

  1. Create a new folder ‘ChangePassword’ and create a new XML file in it ‘feature.xml’:

    XML
    <?xml version="1.0" encoding="utf-8"?>
    <Feature  Id="FEAD7555-AE6D-45DD-8260-13B563CB4C71"
              Title="Change Password"
              Description="Change Password"
              Version="1.0.0.0"
              Scope="Site"
              xmlns="http://schemas.microsoft.com/sharepoint/">
    
    	<ElementManifests>
    		<ElementManifest Location="elements.xml" />
    	</ElementManifests>
    
    </Feature>
  2. Edit feature Id to a unique GUID, you can get it from guidgen in this path C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\guidgen.exe

  3. Edit feature Title, Description and Version as per your need

  4. Edit Scope property to be ‘Site’ or ‘Web’ to indicate if the feature is used per site or in the entire web

  5. In ElementManifest element, set Location property to an XML file location ‘elements.xml’ that contains more feature properties

  6. Create ‘elements.xml’ in the same folder with ‘feature.xml’ to be as:

    XML
    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    	<CustomAction 
    		Id="ChangePasswordMenuId" 
    		Title="Change Password" 
    		Description="Change your password" 
    		Sequence="2000" 
    		Location="Microsoft.SharePoint.StandardMenu" 
    		GroupId="PersonalActions" >
    		<UrlAction Url="~site/_layouts/changepassword.aspx"/>
    	</CustomAction>
    </Elements>
  7. Set CustomAction properties as shown, Location to be ‘StandardMenu’ and UrlAction URL property to be ‘~site/_layouts/changepassword.aspx’ as we are going to add our ChangePassword.aspx to this path.

3. Deployment

  1. Copy ‘ChangePassword.aspx’ file to the following path:
    C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\

  2. Copy ‘ChangePassword’ folder that contains elements.xml and feature.xml to the following path: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\

  3. Open stsadm tool and run the following command:

    stsadm -o installfeature -name ChangePassword 

Image 3

Now the feature is installed successfully, but needs to be activated.

  1. Open your site, the select Site Actions - Site Settings - Modify All Site Settings.
    From the appeared page, select Site Collection Features (under the Site Collection Administration submenu):

    Image 4
  2. The new feature will be listed, Select Activate.

Image 5
  1. Now you can find ‘Change Password’ action in the standard user menu:

    Image 6

    And this action redirects to changepassword.aspx page:

    Image 7

That is all. Thanks a lot!

Thanks

Many thanks to Ahmad Marwan Madkhana for his support.

History

  • 28th December, 2008: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer LINKdotNET (http://www.link.net)
Egypt Egypt
Akram Aly Mossa is an intermediate level software developer, gained many experiences in different fields (development is one of them), born in Egypt 1981, graduated from Al-Azhar university 2005,
and looking for a good future...

Comments and Discussions

 
Question123 Pin
Member 1489271518-Jul-20 0:24
Member 1489271518-Jul-20 0:24 
QuestionCan not change pass Pin
hoang45619-Jun-11 22:31
hoang45619-Jun-11 22:31 
GeneralMy vote of 5 Pin
KaustubhWadi1-Dec-10 20:36
KaustubhWadi1-Dec-10 20:36 
GeneralCancelDestinationURL not working when multiple sites are created Pin
joffies13-Aug-10 5:50
joffies13-Aug-10 5:50 
AnswerRe: CancelDestinationURL not working when multiple sites are created Pin
Akrumooz13-Aug-10 22:03
Akrumooz13-Aug-10 22:03 
GeneralRe: CancelDestinationURL not working when multiple sites are created Pin
joffies15-Aug-10 22:49
joffies15-Aug-10 22:49 
GeneralRe: CancelDestinationURL not working when multiple sites are created Pin
Akrumooz16-Aug-10 1:15
Akrumooz16-Aug-10 1:15 
GeneralRe: CancelDestinationURL not working when multiple sites are created Pin
joffies16-Aug-10 2:28
joffies16-Aug-10 2:28 
GeneralRe: CancelDestinationURL not working when multiple sites are created Pin
Akrumooz16-Aug-10 10:45
Akrumooz16-Aug-10 10:45 
QuestionMOSS Change Password Feature for FBA Pin
sandeeppo29-Apr-10 21:31
sandeeppo29-Apr-10 21:31 
GeneralThank you Pin
bswamy31-Aug-09 0:11
bswamy31-Aug-09 0:11 
GeneralWorks Great, but one issue Pin
wbeach22-Jul-09 11:33
wbeach22-Jul-09 11:33 
GeneralRe: Works Great, but one issue Pin
Akrumooz22-Jul-09 22:43
Akrumooz22-Jul-09 22:43 
GeneralRe: Works Great, but one issue Pin
wbeach23-Jul-09 4:57
wbeach23-Jul-09 4:57 
GeneralGreat article Pin
Yanick Nantchi23-Mar-09 18:09
Yanick Nantchi23-Mar-09 18:09 
QuestionSSL on the change password aspx? Pin
mrbello10-Mar-09 20:15
mrbello10-Mar-09 20:15 
GeneralChangepassword.aspx Pin
sonashish9-Feb-09 5:54
sonashish9-Feb-09 5:54 
AnswerRe: Changepassword.aspx Pin
Akrumooz9-Feb-09 17:36
Akrumooz9-Feb-09 17:36 
Generala question Pin
ShareP26-Jan-09 5:49
ShareP26-Jan-09 5:49 
AnswerRe: a question Pin
Akrumooz26-Jan-09 17:54
Akrumooz26-Jan-09 17:54 
QuestionLooks really cool....but what am I missing Pin
johnmcclain7713-Jan-09 8:51
johnmcclain7713-Jan-09 8:51 
AnswerRe: Looks really cool....but what am I missing Pin
Akrumooz17-Jan-09 0:37
Akrumooz17-Jan-09 0:37 
GeneralExcellent Job Pin
Brij1-Jan-09 18:40
mentorBrij1-Jan-09 18:40 
GeneralRe: Excellent Job Pin
Akrumooz2-Jan-09 4:43
Akrumooz2-Jan-09 4:43 
GeneralGood work Pin
niazi darwish30-Dec-08 20:57
niazi darwish30-Dec-08 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.