Remove Access From Pages

Vote:
 

Hello,

I'm trying to remove groups from CMS pages in the code behind and nothing I have tried seems to be working. Does anybody have an hints, tips or samples of how to do this?

Thanks in advance,

Mark 

#48769
Feb 15, 2011 17:17
Vote:
 

You need to add the role but with AccessLevel.NoAccess. It took me some time before I understood that myself :)

PageAccessControlList acl = new PageAccessControlList(pageRef);
                    acl.Add(new AccessControlEntry(EPiServer.Security.EveryoneRole.RoleName, AccessLevel.NoAccess, SecurityEntityType.Role));
                    acl.Save();

    

#48771
Feb 15, 2011 18:05
Vote:
 

Hi Anders,

Many thanks for that, did the trick nicely. One point to note that I had to remove the acl entry prior to adding again with NoAccess as it complained that the entry already existed (fair enough I suppose). It's strange that the Remove method doesn't persist even when you save the list!!

Thanks again,

Mark

#48807
Feb 16, 2011 10:01
Vote:
 

Can't agree more. That API is a bit cryptical :)

#48808
Feb 16, 2011 10:02
Vote:
 

Could it be that if you just remove Everyone it will inherit Everyone's access righs from the parent? So you have to explicitly add the NoAccess to state that you do not want it to inherit?

#48822
Feb 16, 2011 10:37
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.