How to Hide/Show Menu items based on logon user Credentials..

2 posts, 0 answers
  1. gc_0620
    gc_0620 avatar
    243 posts
    Member since:
    Feb 2008

    Posted 14 Aug 2009 Link to this post

    Folks,

    In my project I have 4 types of users. 1) HR Clerical 2) HR Manager 3) Regular User 4) Regular User Supervisor.

    I am storing users type in a session variable (i.e. Session("UserType") ) after login page.

    My intention is:

    1) If Session("UserType")  = "HR Clerical"  then that user will have only access to Menu Item HR->HR Clerical Functons
    2) If Session("UserType")  = "HR Manager"  then that user will have only access to Menu Item HR and all Child items under it
    3) If Session("UserType")  = "Regular User"  then that user will have access to Menu Items Users->Regular Users Functions 
    Users->Reports 
    4) If Session("UserType")  = "Regular User Supervisorr"  then that user will have only access to Menu Item Users and all Child items under it

    I am using RadControls for ASP.NET AJAX Q2 2009 NET35 with VS 2008 . Below is my Menu Declaration.  Any help will be appreciated. 
                  
    __________________________________________________

    <

     

    telerik:RadMenu runat="server" ID="RadMenu1" Style="float: none; left: 0px; height: 20px;"

     

     

     

    OnItemClick="RadMenu1_ItemClick" Skin="Simple">

     

     

     

    <Items>

     

     

     

        <telerik:RadMenuItem Text="HR">

     

     

     

            <Items>

     

     

     

                <telerik:RadMenuItem Text="HR Clerical Functons">

     

     

     

               </telerik:RadMenuItem>

     

     

     

               <telerik:RadMenuItem Text="HR Manager Functions">

     

     

     

               </telerik:RadMenuItem>

     

     

     

               <telerik:RadMenuItem Text="Reports">

     

     

     

               </telerik:RadMenuItem>

     

     

           </Items>
        </telerik:RadMenuItem>

       <
    telerik:RadMenuItem Text="Users">

     

     

     

           <Items>

     

     

     

               <telerik:RadMenuItem Text="Regular Users Functions">

     

     

     

               </telerik:RadMenuItem>

     

     

     

               <telerik:RadMenuItem Text="Regular User Supervisor Functions">

     

     

     

               </telerik:RadMenuItem>

     

     

     

               <telerik:RadMenuItem Text="Reports">

     

     

     

                 </telerik:RadMenuItem>

     

     

     

           </Items>

     

     

     

       </telerik:RadMenuItem>

    </Items>

     

     

     

    </telerik:RadMenu>

     

     

     

     

     

  2. Paul
    Admin
    Paul avatar
    4281 posts

    Posted 17 Aug 2009 Link to this post

    Hello gc_0620,

    We recommend using the SiteMapDataSource and the security trimming feature. This approach should work with all RadControls which support binding to SiteMapDataSource (toolbar, menu, tabstrip etc).

    If you are using custom implementation of users and roles you need to programmatically remove or hide the items which should not be visible.

    Problems with security trimming can be easily tracked down by using a built-in control along with ours (e.g. asp:Menu or asp:TreeView). If they behave in the same way then the problem is somewhere in your implementation.

    On aside note, security trimming is a feature of the site map provider - it should not be related with the control which is databound.

    You can find more information in Google or read the following MSDN article. Also Scott Mitchell wrote a nice tutorial with source code.
    http://aspnet.4guysfromrolla.com/articles/122805-1.aspx 
    http://msdn2.microsoft.com/en-us/library/ms178428(VS.80).aspx

    Our navigation controls mimic the default ASP.NET menu in terms of sitemap support.

    All the best,
    Paul
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top