I was wonder if there's a better way of retrieve items based on the current logged in user's permissions than I'm currently doing.
Basically, I have this scenario:
A Custom Control which displays images on a RadRotator and a link which points to page.
The RadRotator is configured to display every single imagem on a given Album Id with Lifecycle status as Live.
The link points to a page defined by a Page Id.
If I ain't logged-in and the Album's permissions are set for ie Administrators Only, then Sitefinity will throw a "You are not authorized to 'View album' ('Album')." exception. The same applies for the link, when fetching the PageNode it may also throw this exception.
What I've currently done:
- I've encapsulated the 'var album = LibrariesManager.GetManager().GetAlbum(AlbumId);' on a try catch block and if no exception is thrown then the user has access to it, so I just fetch the available images and display it.
- Same as above for the link, although if an exception is thrown the link won't appear since I can't access the URL.
This is what I'm trying to achieve:
- Check if the User has access to the album, fetch the images he has access to (if permissions are also defined on a per-image rule) and display those, otherwise skip the binding.
- Grab the PageNode despite any permissions it might have, in order to display the link to it, but of course not showing the page when the user browses it since he doesn't have access to it.
Is there a way to perform these checks without using a try catch block in order to catch the unauthorized exception? Like first checking the user permissions against the View permission of the album, then retrieve the images which he has permissions to access? And retrieving a PageNode while totally ignoring the permissions ?
Thanks in advance.