Try our conversational search powered by Generative AI!

Modify parent-inherited ACL on creating a page



I am using CMS R2 SP2 to create a page programmatically, but I want the created page to NOT automatically receive all inherited rights and groups from the parent page.

In effect - I have a parent page with groups Administrators, Editors, CompanyGroup and CoachGroup - and I want the page created to just include the Administrators, Editors and CompanyGroup.

I have tried to set 

PageData newPage = EPiServer.DataFactory.Instance.GetDefaultPageData(parentPageLink, pageTypeId);
newPage.PageName = "New Page";
DataFactory.Instance.Save(newPage, SaveAction.Publish); 

I have tried within the "..." section to do this:

and I have tried to make a clone of the ACL like this:
AccessControlList myAcl = new AccessControlList(newPage.ACL.CreateWritableClone());

The former code block happily saves the ACL and it's gone while I debug, but on the next round or in edit mode the group that I don't want on this particular page is there again.
The latter code block throws an exception on myAcl.Save() that method is not supported.

I have tried some other approaches as well, such as grabbing a writeable clone of the page after the creation, and setting newPage.ACL.IsInherited = false, but the ACL won't budge.

Anyone have any ideas to share with me?

Thanks in advance,

Oct 14, 2009 17:11


Attach to the event CreatedPage, that should be raised after the page is created. If you update the ACL for the page there I can't see a reason why it would be overwritten.

Or perhaps this is one of the things that you've already tried that didn't work?


Per Gunsarfs
EPiServer CMS development team

Oct 16, 2009 15:03

Try to move:


to _after_ the call to DataFactory.Save()


Oct 16, 2009 15:11

Thanks for your suggestions, but...

@Per: It still does not do anything. The group that I removed is present on the page when I check its rights in edit mode.

@Johan: This throws an exception - Object reference not set to an object - on newPage.ACL.Save() . Same thing when I do newPage.ACL.CreateWriteableClone().Save();


Oct 16, 2009 15:26

OK, never mind.

Seems it works if I call DataFactory.Instance.GetPage on the newly created page and set the ACL from there. A bit strange that I can't set it directly on newPage, but at least it works now.

Thanks for the feedback.

Oct 19, 2009 10:28

Look at the page in edit/admin mode for handling Access Control List.

Notice that you select lines that you want to add, edit or delete. So you have to Add what you want to delete to the ACL list.

PageAccessControlList acl = new PageAccessControlList(page.PageLink);
acl.Add(new AccessControlEntry("CoachGroup", AccessLevel.NoAccess, SecurityEntityType.Role));


Notice that you must save the page and retreive it from the DataFactore to get a valid PageLink.
Edited, Oct 19, 2009 22:36

Thanks Fredrik, that cleared a few things up.

Oct 21, 2009 16:07

thanks, Fredrick.  I have been banging my head against a wall with this one all evening!

Mar 18, 2010 0:28

You are welcome! Glad to help!

Mar 22, 2010 15:47
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.