Checking access rights when presenting Link Collection

Vote:
 

I'm using a Link Collection property and have made  a usercontrol that adds custom rendering of the links.

One thing I wan't to do is display a "Secure file icon" if a document resides in a folder that "Everyone" doesn't have read access to.

 I tried doing this with

UnifiedPathInfo pathInfo = new UnifiedPathInfo(path);
AccessControlList acl = pathInfo.Access;
return acl.QueryDistinctAccess(AccessLevel.Read);

But it didn'w work. How can I accomplish this?

Per N

#26384
Dec 03, 2008 11:21
Vote:
 
as input to the above code I set the path variable to linkitem.href;
#26385
Dec 03, 2008 11:33
Vote:
 

dont know if this works but try:

return pathInfo.Access.Exists("Everyone")

 -Kjetil Simensen

#26386
Dec 03, 2008 11:36
Vote:
 

It didn't work.

I tried the below code. If i try to get a file in a folder where everyone has no access I get an exception. That works for a anonymous user. But as soon as I log in I dont get the exception.

 I want to always display the icon if the group Everyone has no access.

//try
//{
// UnifiedFile file = HostingEnvironment.VirtualPathProvider.GetFile(path) as UnifiedFile;

// AccessLevel l = file.QueryAccess();

//}

//catch (UnauthorizedAccessException ex)
//{

// return false;

//}

#26395
Dec 03, 2008 17:20
Vote:
 

Hi

Its the Directory in the filesystem that has access right.

In CMS 5 if you want to check if all users have acces to a file you can use this code 

file.Parent.ACL.QueryDistinctAccess(PrincipalInfo.AnonymousPrincipal, AccessLevel.Read)

 

#26396
Dec 03, 2008 21:28
Vote:
 

Thank you for the answer Anders I figured it out last night. It's also possible to do the below to check the the directotry directly without trying to access the file.

UnifiedDirectory dir = HostingEnvironment.VirtualPathProvider.GetDirectory(path) as UnifiedDirectory.

dir.ACL.QueryDistinctAccess(PrincipalInfo.AnonymousPrincipal,AccessLevel.REad).



 

#26397
Dec 04, 2008 8:19
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.