0

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.

4

1 に答える 1

0

なぜこれをコードで行うのですか?テーマを適用する機能は、「テーマと枠線の適用」権限によって制御されます。デフォルトでは、これは「デザイン」権限レベルに割り当てられています。

すべてのユーザーのアクセス許可を変更しようとするのではなく、サイトのメンバーが適切なアクセス許可を持っていることを確認してください。これを行うには、既定のSharePointサイト グループのアクセス許可を変更するか、必要なアクセス許可を持つ新しいグループを作成します。

さらに、Windows グループにアクセス許可を直接割り当てるべきではありません。SharePoint は、Windows (または AD) グループを SharePoint グループと同じように扱いません。特定の SP グループを作成し、それらに AD グループを割り当てることで、多くの手間を省くことができます。

于 2012-06-06T10:25:12.467 に答える