sharepointpermissionsmysite

How to prevent a mysite owner form deleting the MySite root website


I'm looking for a way to prevent a user in SharePoint from deleting his MySite or be more precise from deleting the MySite's root web site. If I could archive this, I could place some lists the user will also not be allowed to delete.

I first thought about taking the user the right to delete sites but I think this will prevent him also from deleting sub sites he created. So this is not an option as I don't want to limit the use of the MySite.

So what can I do to solve this problem?


Solution

  • You develop a feature that installs code for the WebDeleting event and sets the SPWebEventProperties.Cancel to true depending on your needs.

    You can probably check if the RootWeb.Id is the same as the SPWebEventProperties.WebId, and base your triggering of the SPWebEventProperties.Cancel = true on that.