Checking page access rights/existence based on the page id

Vote:
 
Would anyone around know how do I check user's ability to access a page from just having its id (PageReference)? We currently store some of the page references in a multipage list property but once recovered from the DB there is, naturally, no guarantee that the page can still be instantiated. Other than the page simply ont existing, the regular user cannot access an unpublished or expired pages as well as deleted ones (in recycle bin). Short of instantiating a page and catching an exception around: PageData page = EPiServer.Global.EPDataFactory.GetPage(new PageReference(pageId)); is there a more elegant solution for it? Cheers, Adam
#13179
Aug 28, 2007 14:10
Vote:
 

I would like to have an answer to this myself...

 

/Erik 

#26145
Nov 21, 2008 9:12
Vote:
 

Hi

As far as I know you will need to load the page to check the access rights. Notice however that in the R2 release the GetPage call will always return the page, regardless of the access rights.

I would probobly do something like this:

new FilterAccess.ShouldFilter(GetPage(new PageReference(pageId))) &&
new FilterPublished.ShouldFilter(GetPage(new PageReference(pageId)));

You would still need to catch PageNotFoundExcption though.

Howver when I looked at your sample it seems like you are using EPiServer 4. In that case I don't really know any more elegant solution.

Regards

Per Gunsarfs
EPiServer CMS development team.

#26146
Nov 21, 2008 11:27
Vote:
 

In CMS 5 R2 the Page providers interface do not have any methods for this. Therfore there will be no generic method. But if you look at the DataAccess namespace you wil find some quick methods too get some info.

PageAclDB db=new EPiServer.DataAccess.PageAclDB() ;
DataSet ds = db.List(new PageReference(3));

Its a bit hardcore and you need to convert form DataSet tol acl but its maybe quicker.

I even guess you can make your own version of this where you can check more than one pagereference (use Refletor). EPiServer always read only one page at the time and that have a big impact on preformance in cms 4. CMS 5 is a lot better but thats cause of the cache.

#26152
Nov 21, 2008 18:32
* 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.