More in this section

Forums / Developing with Sitefinity / security for page

security for page

2 posts, 0 answered
  1. Sridhar Kamalakkannan
    Sridhar Kamalakkannan avatar
    2 posts
    Registered:
    09 Dec 2008
    11 Nov 2009
    Link to this post
    Hi Here is what I am trying to do ....
    I would like to construct an array list out of the ICMSPages, where the user has view permissions - I would like to point out that I am using a custom role provider.

    here is a piece of code 


        private IList GetPagesFromCMS()  
        {  
            CmsManager cManage = new CmsManager();  
            IList iList = cManage.GetPages();      
            return iList;  
        }  
     
     
        private IList GetMenuNavigationPagesFromCMS()  
        {  
            IList iCMSPageList = GetPagesFromCMS();  
            List<ICmsPage> iCMSMenuPageList = new List<ICmsPage>();  
            IEnumerator iEnum = iCMSPageList.GetEnumerator();  
     
            while (iEnum.MoveNext())  
            {  
                ICmsPage iECurrentPage  = (ICmsPage)iEnum.Current;  
     
                if ((iECurrentPage.Parent == null) && (iECurrentPage.Navigable) && (CheckPageSecurity(iECurrentPage)))  
                {   iCMSMenuPageList.Add(iECurrentPage);  
                }  
              
            }  
            iCMSMenuPageList.Sort(delegate(ICmsPage iCMSP1, ICmsPage iCMSP2) { return iCMSP1.Ordinal.CompareTo(iCMSP2.Ordinal);});   
            return iCMSMenuPageList;  
              
        }  
     
     
     
     
        private bool CheckPageSecurity(ICmsPage iCPage)  
        {  
            Telerik.Security.UserManager uManager = new Telerik.Security.UserManager();  
            string strUser = Telerik.Security.SecurityManager.GetCurrentUserName();  
     
            uManager.GetRolesForUser(strUser);  
            //Permission pPermission = new PagePermission(iCPage);  
     
            return true;  
     
            /*  
              
            return pPermission.CheckDemand();  
          
             */  
         } 

    It is the CheckPagesecurity where I do get stuck, how can I receive the Permissions for a Page - Every single time it brings the default sitefinity provider and the CMS Users however I would like to see my Custom Provider and some way to verify that the user 's role has permissions to view this page.

    Cheers
    Sridhar 
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Nov 2009
    Link to this post
    Hi Sridhar Kamalakkannan,

    Try using the code below:

    MembershipUser user = Membership.Providers["CustomProvider"].GetUser("someuser", false)
    string[] roles = Roles.GetRolesForUser();

    Let us know if you need further assistance.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered