SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to take a backup of sitecollection whenever user tried to delete it. I am using SiteDeleting(SPWebEventProperties properties) event for this. One constraint is, i need to cancel the delete if the user is not siteadmin. My question is, how to cancel the delete if the user is not site admin.

bool res = properties.Web.UserIsSiteAdmin();            
          if (res)

i have already done with the backup part but need to know how to cancel the delete.

Thanks in advance!

share|improve this question

In your SPWebEventProperties you have a Cancel and an ErrorMessage property that you can use to cancel the event.

    properties.Cancel = true; // setting this will change Status property from Continue to Cancel-WithError
    properties.ErrorMessage = "You are not allowed to delete this site";

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.