SharePoint: How to Hide Delete Site


Site Owners can delete their own sites. A cool power user feature, but… do you trust them with this power?

Before we go on, even if you remove the ability to delete a site, you should still install the site undelete tool from CodePlex.  Just in case, you know…

Here’s two ways I’ve thought of to deal with Delete Site…

  • Replace the Delete Site page
  • Hide the Delete Site link using a feature

(both require access to the web servers)


Idea #1 – Get rid of the site delete page!

Well, not get rid of it, but hide it. The site delete page is in the 12 hive: …\12\template\layout\deleteweb.apx.  The quickest way to make this page unavailable is to just rename it, say to deletewebforadminonly.aspx. You can then still use the page to delete a site by going directly to http://servername/sitename/_layouts/deletewebforadminonly.aspx.

What will the site owners see if they click the Delete Site link? The standard SharePoint “Unknown Error” error page. Want something better? After renaming the deleteweb page create a new deleteweb page with something like “To delete this site please contact your SharePoint Administrator at 123-1234”.

Sample deletesite.aspx page:

<%@ Page Language="C#" MasterPageFile="~/_layouts/application.master"%>

<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
Delete Web Site
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
Delete Web Site
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
The "Delete Site" command has been disabled. <br><br>
To delete this site please contact your SharePoint Administrator


Idea #2 – Use a Feature:

A SharePoint feature can be enabled and disabled at any time without modifying a site or page. Using this feature described here will hide the Delete Site command from your Site Owners, but they can still go directly to the deletesite.aspx page if they can guess the URL.

Create these files in the Features folder with a name like: …\12\Features\HideDeleteSite

In the feature.xml file pick the Scope you would like to use: Farm, WebApplication, Site or Web.


<?xml version="1.0" encoding="utf-8"?>
<Feature Id="00BFEA71-A83E-497E-9BA0-7A5C597D0106"
    Title="Hide the Delete Site option"
    Description="Remove the ability for the site owner to delete sites."
        <ElementManifest Location="HideDeleteSite.xml" />


<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      Location="Microsoft.SharePoint.SiteSettings" />


Then run the STSADM’s install feature command.

STSADM -o installfeature -name HideDeleteSite

Go to Central Admin or the site or site collection, depending on the scope you selected, and enable the feature.


Watch outs, got-yas, etc.

  • If you delete or rename deletesite.aspx you may find it restored after a service pack update.
  • If you use a Feature, remember that if you set the Scope to Web or Site the Site Owner or the Site Administrator will be able to disable it.
  • Remember to add this little fix to your disaster plan. Just one more thing to do when you have to rebuild your servers, or add a new web server to the farm.


No comments:

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.