配置好了sharepoint 2013基于AD的Form登录,只是成功了第一步,如何自定义登录页呢?特别是不要出现sharepoint2013自带登录页面,每次登录前还需要选择是否是form或者windows验证。
打开vs2012新建sharepoint 2013 project,在layouts目录下添加application page,页面命名为CustomLogin.aspx。
前台页面:为避免母版页中其他控件影响,注意继承的是simple.master
后台页面:继承FormsSignInPage类。
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %> <%@ Assembly Name="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Assembly Name="Microsoft.SharePoint.IdentityModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %> <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomLogin.aspx.cs" Inherits="ESSE.Sharepoint.Authentication.Layouts.CustomLogin" MasterPageFile="~/_layouts/simple.master" %> <asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server"> <SharePoint:EncodedLiteral runat="server" EncodeMethod="HtmlEncode" ID="ClaimsFormsPageTitle" Visible="false" /> My Custom Login </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server"> <SharePoint:EncodedLiteral runat="server" EncodeMethod="HtmlEncode" ID="ClaimsFormsPageTitleInTitleArea" Visible="false" /> </asp:Content> <asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSiteName" runat="server" /> <asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderMain" runat="server"> <SharePoint:EncodedLiteral runat="server" EncodeMethod="HtmlEncode" ID="ClaimsFormsPageMessage" Visible="false" /> <asp:Login ID="signInControl" FailureText="<%$Resources:wss,login_pageFailureText%>" runat="server" Width="100%" DisplayRememberMe="false" /> </asp:Content>
using System; using Microsoft.SharePoint.IdentityModel.Pages; namespace Contoso.SharePoint.Authentication { public partial class Login : FormsSignInPage { protected void Page_Load(object sender, EventArgs e) { } } }