PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(newSite); PublishingPageCollection allPages = publishingWeb.GetPublishingPages(); foreach (PublishingPage page in allPages) { Console.WriteLine(page.Name); if (page.Name.ToLower() == "about us.aspx" || page.Name.ToLower() == "people.aspx" || page.Name.ToLower() == "services.aspx") { #region checkout and assign the permissions to intranet_readers // checkout the page if (page.ListItem.File.CheckOutType == SPFile.SPCheckOutType.None) { page.CheckOut(); } else { page.ListItem.File.UndoCheckOut(); page.CheckOut(); } // Break the permissions page.ListItem.BreakRoleInheritance(true); // Rename the page //page.ListItem["Name"] = "About us"; // Assign the permissions to intranet_readers SPRoleAssignment roleAssignment = new SPRoleAssignment(newSite.SiteGroups["readersgroup"]); if (roleAssignment != null) { roleAssignment.RoleDefinitionBindings.Add(newSite.RoleDefinitions["Read"]); page.ListItem.RoleAssignments.Add(roleAssignment); page.ListItem.Update(); } // CheckIn the page page.CheckIn("Broken permissions added"); // publish the page SPModerationInformation moderationInformation = page.ListItem.ModerationInformation; if (moderationInformation != null && moderationInformation.Status != SPModerationStatusType.Approved) { SPFile pageFile = page.ListItem.File; pageFile.Publish("publish comments"); pageFile.Approve("approve comments"); } #endregion } }
Wednesday, December 10, 2014
Assign broken permissions to publishing pages through programtically
Subscribe to:
Post Comments (Atom)
Image noise comparison methods
1. using reference image technique - peak_signal_noise_ratio (PSNR) - SSI 2. non-reference image technique - BRISQUE python pac...
-
No Risk Details 1 Version Disclosure (ASP.NET) Description: This information can be found in HTTP Response Header w...
-
Some times, when working with the Multiline fields, they may occupy the whole page :-). We can solve this issue by introducing Expand-Coll...
-
Artificial Intelligence is the broader umbrella under which Machine Learning and Deep Learning come. And you can also see in the diagram th...
No comments:
Post a Comment