UPDATED: 16-MAY-2008
Overview
How can you get the PageData object for a page when the current user doesn't have access. It took me a while to find out, but you can just read on...
Context
I have been implementing a redirect facility. Only editors and administrators are allowed access to the page and everyone else is redirected according to a property on the page. The ACL on the page does not give Read access to the Everyone group. How can I get the property?
Solution
The easy solution is to use EPiServer 5. Then you can use the GetPage method of the DataFactory class to get a page, and provide the access level:
UPDATED: Thanks to Steve Celius of EPiServer for a better solution for EPiServer 4.6
Link to Steve Celius' blog: http://labs.episerver.com/en/Blogs/Steve-Celius/
In EPiServer 4.6, the EPiServer.Security.AccessLevel enumeration does not include a NoAccess member. However, the EPiServer.Security.AccessControlList.NoAccess property is an instance of EPiServer.Security.AccessLevel and can be used directly.
THE METHOD I ORIGINALLY POSTED IS BELOW, BUT DO NOT USE IT!!!
However, I was using EPiServer 4.6 for this project, and the luxury of a NoAccess access level was not given to me!
In this case, you need to circumvent the EPiServer security model. Of course, this probably isn't supported! The following code does the job:
EPiServer.DataAccess.PageLoadDB pageLoadDB =
new EPiServer.DataAccess.PageLoadDB();
EPiServer.Core.PageData page =
pageLoadDB.Load2(pageReference);
Job done!
Versions
Metadata