Thursday, January 20, 2011

Sharepoint RoleAssignement exception "This operation is not allowed on an object that inherits permissions."

If you are getting This operation is not allowed on an object that inherits permissions. exception when setting roles (User groups to website), here is the fix.

You need to break the permission inherited by the subsite from sitecollection. This will let you set Users and Groups independently for the subsite. Here is the code piece.

using (SPWeb web = site.OpenWeb("MySite"))
{
    web.BreakRoleInheritance(true);
    //Rest of RoleAssignment logic
}

Hope this helps.

No comments:

Post a Comment