Permissions & Content Retrieval
Greetings,
Hi Daniel,
You can check the permissions for a library and then image as the code sample below illustrates.
var manager = LibrariesManager.GetManager(LibrariesManager.GetDefaultProviderName());
var alb = manager.GetAlbums().Where(a => a.Title ==
"Default Album"
).SingleOrDefault();
var permVew = alb.IsGranted(SecurityConstants.Sets.Album.SetName, SecurityConstants.Sets.Album.View);
if
(permVew)
var items = alb.Items;
var img = items[0]
as
MediaContent;
var imgPerm = img.IsGranted(SecurityConstants.Sets.Image.SetName, SecurityConstants.Sets.Image.View, SecurityConstants.Sets.Image.Manage);
if
(imgPerm)
var alertText =
"<script type=\"text/javascript\">"
+
"alert('allowed');</"
+
"script>"
;
Page.ClientScript.RegisterClientScriptBlock(
this
.Page.GetType(),
"found"
, alertText);
Hello Ivan,
Hi Daniel,
You can crate a helper method or class to do this
public
Boolean CheckID(
string
ID)
var pm = PageManager.GetManager();
var pageData = pm.GetPageData(
new
Guid(ID));
if
(pageData !=
null
)
return
true
;
return
false
;
Thank you Ivan, that solved my first issue. Was trying to do the exact same thing but while using the GetPageNode and using that method it would throw an exception, but GetPageData instead worked as it will return null.
Hello Daniel,
In the BETA it is not possible to handle 403 status code of the error. By default the ASP.NET SiteMapProvider also does not return information whether the page is not accessible or it is not presented in the current sitemap. Since we follow the default implementation of ASP.NET SiteMapProvider we are also affected from this issue and we are working on a solution about this issue.
Greetings,
Ivan Dimitrov
the Telerik team
Hello Joe,
This is also the default behavior of the ASP.NET SiteMapProvider which we have wrapped. It does not return information whether the page is not accessible or it is not presented in the current sitemap. As you might have noticed from my previous post we are working on this. For the time being there is no workaround to this issue. You cannot get a correct response whether the page is not found or you do not have permissions, because ASP.NET SiteMapProvider always returns that this page does not exists.
All the best,
Ivan Dimitrov
the Telerik team
Thanks Ivan,
It don't work even in RC2, which is a real pain...
Hello ,
The issue has been escalated. The "issue" is logged with ID #73553: Error Handling + Custom error pages.
We will try to implement the error handling next week. I am sorry for the troubles that this might have caused.
Regards,
Ivan Dimitrov
the Telerik team