您的位置:首页 > 其它

Sharepoint如何自定义“拒绝访问”页面

2013-04-18 22:10 274 查看
  在Sharepoint中,没有权限的情况下,会跳转到“拒绝访问”页面,路径一般是:/_Layouts/AccessDenied.aspx,如果我们想实现自定义页面,提示用户如何申请权限或提交申请权限请求,那么我们就需要修改此页面。

  1.直接修改AccessDenied.aspx页面

  我们可以直接到C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS找到此文件编辑修改,由于LAYOUTS目录是公用的,所以改过以后会造成服务器上所以的站点都会更改,最好的解决方案是将LAYOUTS拷贝到其他目录,在IIS站点下新建_Layouts虚拟目录,然后再进行修改。

  注意:此方法在升级SharePoint、重新配置站点后需要重新进行修改操作

  2.使用SPWebApplication.UpdateMappedPage(SPCustomPage,PageURL)

  编写一控制台程序,在服务器端执行

  

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace MapCustomAppPage
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://spsite"))
{
SPWebApplication webApp = site.WebApplication;

webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, "/_layouts/CustomAccessDenied.aspx");
webApp.Update();

Console.ReadKey();
}
}
}
}


  如果要恢复到默认页面,则修改代码webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, "/_layouts/CustomAccessDenied.aspx");为:webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, null);

  注意:PageURL必须在"/_layouts/"下。

  或者使用Power Shell进行修改

$webApp = Get-SPWebApplication http://test $webApp.UpdateMappedPage([Microsoft.SharePoint.Administration.SPWebApplication+SPCustomPage]::AccessDenied,"/_layouts/1033/CustomAccessDenied.aspx")
$webApp.Update()


  

  其他参考:http://sharepoint403page.codeplex.com/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: