1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / How to get role details assigned to Page in Permission

How to get role details assigned to Page in Permission

7 posts, 0 answered
  1. Fareed
    Fareed avatar
    5 posts
    Registered:
    11 May 2011
    12 Jul 2011
    Link to this post
    Hello,
    I am implementing an application where i need to know dynamically the role assigned to the pages.  I am looking to your forum however there is no solution provided and also trying several approaches for this but no luck. Please let me know how to get role assigned to pages in permission so that I continue my work.
    It has become blocker for me to continue my work. I will be grateful for quick response from your side.
    Awaiting for the response.

    Thanks
    Fareed Khan
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    12 Jul 2011
    Link to this post
    Hi Fareed,

    There is entire section in our dev manual that explains the permissions. Please take a look at it.

    Regards,
    Ivan Dimitrov
    the Telerik team
    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
  3. Fareed
    Fareed avatar
    5 posts
    Registered:
    11 May 2011
    12 Jul 2011
    Link to this post
    Thanks Ivan, for the reply. I have gone through the dev guide. It includes the Role managment for users however i m looking for role assigned to Pages. How to get the roles of the pages. Please help in this scenario with some useful example. Your guidance will be great support for me to continue my work.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    12 Jul 2011
    Link to this post
    Hi Fareed,

    First you need to identify for which permission set you will get the role. Each permission set could have role or user assigned. The page has permissions. Permissions are associated with roles, so we assign permissions to a role and permissions to a page, but not role to page

    Below is a sample code


                var manager = PageManager.GetManager();
                var roleID = new Guid("263d4a0a-9e35-4d30-ad13-edac983cde39");
                var pgID = new Guid("439A6A30-D2C2-4EE7-A148-2344BB5CC4E6");
                var mp = App.WorkWith().Page(pgID).Get();
                var checkPerm = manager.GetPermission(SecurityConstants.Sets.Pages.Delete, mp.Id, roleID);

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    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
  5. Fareed
    Fareed avatar
    5 posts
    Registered:
    11 May 2011
    12 Jul 2011
    Link to this post
    Thanks for the example and details.

    My scenario is that when somebody hit the page or request for the particular page, then we need to know which role is set in the permission for that page to view the page. We would need to have Role details so that we can use in our further implementation in application. So in this case we don't know which role is set in permission for page. I need to get that role which is set for page. Please let me know what can i do in this case as GetPermsission() methods need Role id.But here i need to get role ID only for that page.

    Please hlep me so that i could continue my work.

    Thanks
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    12 Jul 2011
    Link to this post
    Hi Fareed,

    For this case you can use GetActivePermissions which returns all permissions for this item by an expression of Permission objects. From the permission object you can get

    - grant/deny action.
    - ObjectId - the object you query
    - PrincipalId the role with permissions.

    sample
         
    var pg = SiteMapBase.GetActualCurrentNode();
    var pm = PageManager.GetManager();
    var pn =pm.GetPageNode(pg.Id);
    var activePerm =  pn.GetActivePermissions();
    var getGrant = activePerm.First().Grant;
    var itemInQuery = activePerm.First().ObjectId;
    var roleID = activePerm.First().PrincipalId;



    Best wishes,
    Ivan Dimitrov
    the Telerik team
    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
  7. Fareed
    Fareed avatar
    5 posts
    Registered:
    11 May 2011
    12 Jul 2011
    Link to this post
    Thanks so much.
    Could we use PageDataList() of class PageData instead of PageNode as in my scenario I am not having data through PageNode. Please suggest me getting alternative way to use PageNode for your given example.

    Thanks for all ur support
7 posts, 0 answered