- AccessDenied (Specifies AccessDenied.aspx)
- Confirmation (Specifies Confirmation.aspx)
- Error (Specifies Error.aspx)
- Login (Specifies Login.aspx)
- RequestAccess (Specifies ReqAcc.aspx)
- Signout (Specifies SignOut.aspx)
- WebDeleted (Specifies WebDeleted.aspx)
Microsoft.SharePoint.ApplicationPages
Il est aussi nécéssaire de modifier la masterpage de votre page d'application par :
MasterPageFile="~/_layouts/simple.master"
Et d'hériter la classe correspondante
UnsecuredLayoutsPageBase pour AccessDenied.aspx par exemple.
La modification de ces pages peut ensuite se faire de deux manières, soit par code C# :
SPWebApplication.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied,
"_layouts/MyAccessDenied.aspx);
Soit via powershell :
Set-SPCustomLayoutsPage -Identity "AccessDenied" -RelativePath
"/_layouts/MyAccessDenied.aspx" -WebApplication http://serveur
Get-SPCustomLayoutsPage –Identity "AccessDenied" -WebApplication http://serveur
iisreset
Voici une page complète d'une customisation simple de la page AccessDenied.aspx avec changement du lien 'Retour au site' par défaut :
<%@ Assembly Name="Name, Version=1.0.0.0, Culture=neutral,PublicKeyToken=092c1c010b5e2820" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.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=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AccessDenied.aspx.cs" Inherits="AccessDenied" MasterPageFile="~/_layouts/simple.master" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="Microsoft.SharePoint.Publishing" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="Microsoft.SharePoint.WebControls" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (SPContext.Current != null && SPContext.Current.Web != null && SPContext.Current.Web.CurrentUser != null)
{
LabelUserName.Text = SPContext.Current.Web.CurrentUser.LoginName;
}
if (SPContext.Current != null && SPContext.Current.Web != null && SPContext.Current.Web.Site != null
&& SPContext.Current.Web.Site.WebApplication != null)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "click",
"modifierRetour('" + SPContext.Current.Web.Site.WebApplication.Sites[0].Url + "');", true);
}
// HLinkLoginAsAnother.Attributes.Add("onclick", "LoginAsAnother('\u002fsites\u002factuariat\u002f_layouts\u002fcloseConnection.aspx?loginasanotheruser=true', 1)");
// HLinkLoginAsAnother.NavigateUrl = "http://www.google.com/";
}
</script>
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
<style type="text/css"></style>
<script type="text/javascript">
function modifierRetour() {
var backbutton = document.getElementById('ctl00_PlaceHolderGoBackLink_idSimpleGoBackToHome');
if (backbutton != null) {
backbutton.href = "javascript:history.back()"; // cacherBackToSite.arguments[0];
}
}
</script>
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<table border="0" cellpadding="0">
<asp:Panel id="PanelUserName" runat="server">
<tr>
<td class="ms-sectionheader">
<%--<img src="/_layouts/images/ListSet.gif" alt="" />--%>
<SharePoint:EncodedLiteral ID="EncodedLiteral3" runat="server" text="<%$Resources:wss,accessDenied_currentuser%>" EncodeMethod='HtmlEncode'/>
</td>
</tr>
<tr>
<td valign="top" class="ms-descriptiontext"><SharePoint:EncodedLiteral ID="EncodedLiteral4" runat="server" text="<%$Resources:wss,accessDenied_loggedInAs%>" EncodeMethod='HtmlEncode'/>
 <b><asp:Label id="LabelUserName" runat="server"/></b>
</td>
</tr>
</asp:Panel>
</table>
</asp:Content>
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
<SharePoint:EncodedLiteral ID="EncodedLiteral1" runat="server" text="Accès refusé au site demandé" EncodeMethod='HtmlEncode'/>
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
<SharePoint:EncodedLiteral ID="EncodedLiteral2" runat="server" text="Vous n'avez pas le droit de visualiser ce site." EncodeMethod='HtmlEncode'/>
</asp:Content>
Aucun commentaire :
Enregistrer un commentaire