Permissions and Authenticated users
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
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"
);
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