locked
Left Navigation Bar based on roles RRS feed

  • Question

  • Hi,

    I'm new to SharePoint and not sure where to start.  This is what I need to achieve

    " I need to create a left navigation bar which shows menu items based on roles. After done with this role-based navigation, I also need to satisfy a scenario where same menu item clicked by two different roles should take him to different URL's. For Example say there is something like 'Reports' in the menu item. So, if User of role1 clicks the 'Reports' menuitem, it should navigate to a URL where reports of his department exist and if user of role2 clicks 'Payroll' menuitem, then he needs to be navigated to a different URL."

    I did some research regarding the second part after setting up left navigation bar and found out that I can create a custom list in SharePoint with  the role, url as columns and navigate him to appropriate page by checking it from custom code.  But I'm quite confused on how to set-up the role-based left-navigation bar. Should I be using the OOTB navigation  or should I be creating one from scratch in Visual Studio. I'm certainly not sure how and where to start this. Any help would be greatly appreciated.

    Thank You.


    Thursday, February 28, 2013 12:17 AM

Answers

  • HI,

    There's a basic difference between audience vs SharePoint roles. Audiences are not stopping users to access the links instead to show/hide links based on user audience. SharePoint roles related to permissions. If a user doesn't have permission the user can't access the links. So if you use audience then you need to make sure the individual links are secured for appropriate SharePoint roles. Personally I think you should go for Roles instead of Audience as audiences sometimes go out of control. If you continue using audiences, sometimes later you will find there's 100 of audiences used in different places in your SharePoint site and you don't know where and how.

    About query string, since the left hand navigation will be visible all the time, I mean in every page in the site, you can't pass querystring in every pages. That will be a big challenges to pass querystring in each and every page. Even if user might try to manipulate the querystring. Instead if you use SPContenxt.Current.Web.CurrentUser, then you can access currently logged in users' roles,permissions. Based on this property you can show/hide menu and you don't need querysting.


    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

    • Marked as answer by GuYuming Monday, March 4, 2013 6:31 AM
    Friday, March 1, 2013 12:39 AM

All replies

  • Hi,

    Since you have very dynamic logic, I would recommend you to build the left navigation programmatically based on current user's roles. You need to replace the current left navigation with your own. Please follow the link for details: http://www.chaitumadala.com/2011/08/how-to-customize-current-navigation.html

    For the solution provided in the link, you need to modify the master page as well as deploy a wsp.


    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

    Thursday, February 28, 2013 6:56 AM
  • HI Sohel,

    Thanks for the advice. The link would certainly be helpful.

    But I have a small doubt. Is it possible to use audiences for the first part for setting up role based navigation and then for the second part write custom code by passing role as query string?

    Thanks.

    Thursday, February 28, 2013 9:46 PM
  • HI,

    There's a basic difference between audience vs SharePoint roles. Audiences are not stopping users to access the links instead to show/hide links based on user audience. SharePoint roles related to permissions. If a user doesn't have permission the user can't access the links. So if you use audience then you need to make sure the individual links are secured for appropriate SharePoint roles. Personally I think you should go for Roles instead of Audience as audiences sometimes go out of control. If you continue using audiences, sometimes later you will find there's 100 of audiences used in different places in your SharePoint site and you don't know where and how.

    About query string, since the left hand navigation will be visible all the time, I mean in every page in the site, you can't pass querystring in every pages. That will be a big challenges to pass querystring in each and every page. Even if user might try to manipulate the querystring. Instead if you use SPContenxt.Current.Web.CurrentUser, then you can access currently logged in users' roles,permissions. Based on this property you can show/hide menu and you don't need querysting.


    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

    • Marked as answer by GuYuming Monday, March 4, 2013 6:31 AM
    Friday, March 1, 2013 12:39 AM
  • n1shan1h,

    Instead of developing a custom solution from scratch, you can add a JavaScript/jQuery code in your master page to access the quick launch menu elements and customize them based on the currently logged in user. You can user ECMAScript client object model to determine the rols of the currently logged in users. Have a look at this link.


    Regards,
    SC Vinod
    Blog
    : http://sharesilver.wordpress.com/

    Friday, March 1, 2013 4:45 AM
  • You can develop a custom web part for the left navigation with following steps

    1) Create a custom list where in you will enter all the navigation menu with parent child relation ship, link and people, group picker for assigning access on the link

    2) In the web part through code using SharePoint object model you can read the list and based on the assigned access in the list you can fetch all the links for the current user and display them accordingly as per the parent child relation ship


    Mark this post as answer if this resolves your issue.


    Everything about SQL Server | Experience inside SQL Server -Mohammad Nizamuddin

    Friday, March 1, 2013 4:57 AM
  • In Site Settings->Site Collection Administration->Site Collection navigation, there is an option called Enable Security Trimming. when checked, user won't see links for library for which he does not have permission on left navigation.
    • Proposed as answer by Avni Bhatt Tuesday, May 6, 2014 8:25 AM
    Monday, March 4, 2013 6:30 AM