在Microsoft OfficeSharePointServer 2007(MOSS 2007)中启用基于表单的身份验证意味着用户凭据存储在类似于ASP.NET的会员数据库中。然而,MOSS并没有提供用户在该数据库中更改密码的便利方式。本文将介绍如何在MOSS 2007中添加一个新功能——密码更改功能,以解决这一问题。
启用基于表单的身份验证后,用户需要一个界面来更改其密码。但是,MOSS 2007默认并没有提供这样的功能。
建议是在标准用户菜单中添加一个新的功能(密码更改功能),该功能将用户重定向到一个自定义页面(ChangePassword.aspx),提示用户输入当前密码和新密码。
如果不想详细了解解决方案的每一步,可以直接使用附带的文件,并跳转到第三部分“部署”。实际上,这个解决方案来源于Sheetal Jain的博客,但增加了细节和澄清。
可以使用Visual Studio创建一个新的网站“TempSite”,然后:
        <%@ 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>
    
在开始之前,这里有一个创建MOSS自定义功能的教程:
        <?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>
    
编辑feature Id为一个唯一的GUID,可以从Visual Studio的guidgen工具中获得。根据需要编辑feature的Title、Description和Version。设置Scope属性为‘Site’或‘Web’,以指示该功能是用于每个站点还是整个网站。
        <?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>
    
按照所示设置CustomAction属性,Location设置为‘StandardMenu’,UrlAction的URL属性设置为‘~site/_layouts/changepassword.aspx’,因为将把ChangePassword.aspx添加到这个路径。
将‘ChangePassword.aspx’文件复制到以下路径:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\
将包含elements.xml和feature.xml的‘ChangePassword’文件夹复制到以下路径:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\
打开stsadm工具并运行以下命令:
stsadm -o installfeature -name ChangePassword
现在功能已成功安装,但需要激活。打开站点,选择“站点操作” - “站点设置” - “修改所有站点设置”。从出现的页面中,选择“站点集合功能”(在“站点集合管理”子菜单下):
新功能将被列出,选择“激活”。现在可以在标准用户菜单中找到“更改密码”操作:
这个操作将重定向到changepassword.aspx页面:
就是这样。非常感谢!