I am new to sharepoint 2010. i would like to restrict the users to change theme other than site admins using feature in sharepoint 2010. I tried the below code to do the same.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
SPPolicyRole RestrictThemes;
//we are removing the ApplyStyleSheets permission and ApplyThemeAndBorder permission by passing this
//to Policyroles.
SPBasePermissions RestrictPermissions = SPBasePermissions.ApplyStyleSheets | SPBasePermissions.ApplyThemeAndBorder;
//we are not granting any permissions
SPBasePermissions GrantPermissions = new SPBasePermissions();
RestrictThemes = webApp.PolicyRoles["Restrict Themes"];
if (RestrictThemes == null)
{
RestrictThemes = webApp.PolicyRoles.Add("Restrict Themes", "Restricts themes to be modified by anybody",
GrantPermissions,
RestrictPermissions);
webApp.Update();
}
SPPolicy policy = webApp.Policies.Add("NT Authority\\Authenticated users", "All Authenticated Users");
policy.PolicyRoleBindings.Add(RestrictThemes);
webApp.Update();
});
But when i try this code, it isn't allowing even site admins. Please provide any idea or suggestions.
Thanks in advance.