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:

EPiServer.Core.PageData page =
  EPiServer.DataFactory.Instance.GetPage(
    pageReference, 
    EPiServer.Security.AccessLevel.NoAccess);

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


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Thursday, January 31, 2008 8:53 AM | in EPiServer Security Software Development

Comments

Gravatar
# re: EPiServer: Getting a PageData Object When You Do Not Have Access to the Page
Posted by Håkan
on 2/25/2008 3:01 PM
Thanks for the tip. However EPDataFactory is marked deprecated in version 5. It might be better to use the code below.

EPiServer.Core.PageData page = EPiServer.DataFactory.Instance.GetPage(pageRef, EPiServer.Security.AccessLevel.NoAccess);
Gravatar
# re: EPiServer: Getting a PageData Object When You Do Not Have Access to the Page
on 2/25/2008 5:56 PM
Thanks for that. I've updated the article.
Gravatar
# re: EPiServer: Getting a PageData Object When You Do Not Have Access to the Page
Posted by Steve Celius
on 5/16/2008 10:58 AM
In v4.x use EPiServer.Security.AccessControlList.NoAccess to specify that no access check should be done.

Post Comment

Title *
Name *
Email
Url
Comment *  


Please add 1 and 3 and type the answer here: