Permissions and Authenticated users

Posted by Community Admin on 04-Aug-2018 19:16

Permissions and Authenticated users

All Replies

Posted by Community Admin on 31-Oct-2013 00:00

Hi

I am trying to set permissions on a page via the Sitefinity API. I have followed Boyan Barnev's excellent blog post at http://www.sitefinity.com/blogs/boyan-barnevs-blog-/2013/06/19/working-with-sitefinity-permissions-api---managing-permissions which has allowed me to add a permission.

The end point is to have the page only able to be viewed by a specific role. The page is possibly inheriting the permission allowing Authenticated users to view the page. When I view the permissions after running my code, I see Authenticated users and the role I added have view permission. I would like to deny or revoke or remove this permission as it is not required.

The line I use to add the new permission is
perm.GrantActions(false, new string[] SecurityConstants.Sets.Pages.View );
where perm is a Permission.

I thought the first parameter (Append), when set to false, would replace any existing permissions or is this incorrect?

All the examples use the ID of the objects involved. I can't seem to find out how to get the id of the "Authenticated" role, or is there something else I need to look for?

Thanks,
David

Posted by Community Admin on 05-Nov-2013 00:00

Hello David,

Thank you for contacting us.

To use the context of Boyan's sample, you can just change the user, to a role by getting the role manager for AppRoles and then getting the Authenticated role:

var rolemanager = RoleManager.GetManager("AppRoles");
             
var user = rolemanager.GetRole("Authenticated");
 
And the sample will be applied for the role instead of the user.


Regards,
Atanas Valchev
Telerik
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 07-Nov-2013 00:00

Hi Atanas

Thanks for your reply on how to get the Authenticated role.

The solution to the problem of clearing permissions for a clean slate, is to call .Clear() on the permissions collection, for future reference. Once this is done, it is possible to add whatever permissions are required.

Thanks,
David

This thread is closed