破坏网站(SharePoint、C#)的安全继承

本文关键字:安全 继承 网站 SharePoint | 更新日期: 2023-09-27 18:20:44

下面的代码片段破坏了列表的安全继承。

        string siteUrl = "http://MyServer/sites/MySiteCollection";
        ClientContext oContext = new ClientContext(siteUrl);
        SP.List oList = oContext.Web.Lists.GetByTitle("Announcements");
        oList.BreakRoleInheritance(true, false);
        oContext.ExecuteQuery();

我如何为网站做同样的事情?参考:http://msdn.microsoft.com/en-us/library/ee535228.aspx

破坏网站(SharePoint、C#)的安全继承

基本上你可以使用:

SPWeb web = SPContext.Current.Web;
web.BreakRoleInheritance(true, false);

参考:SPWeb.BreakRoleHeritage方法