Authentication and user based content

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Devlon

    Authentication and user based content

    Hi,

    I've created a small application with some user-authentication and roles.

    I would like to show/hide some navigation parts based on the users role.

    Could someone please tell me what the best solution is?

    Do I have to create different pages for each role and check the users role
    when logged in?

    Thanx

    Kind regards

    John


  • Eliyahu Goldin

    #2
    Re: Authentication and user based content

    You can use different sitemaps for different roles.

    If you have 2 providers in the web.config

    <siteMap enabled="true">
    <providers>
    <add name="Role1Site MapProvider" description="Si teMap for role 1."
    type="System.We b.XmlSiteMapPro vider"
    siteMapFile="Ro les/Role1/Role1.sitemap" />
    <add name="Role2Site MapProvider" description="Si teMap for role 2."
    type="System.We b.XmlSiteMapPro vider"
    siteMapFile="Ro les/Role2/Role2.sitemap" />
    </providers>
    </siteMap>

    you can set SiteMapProvider property for navigation controls in the code to
    either Role1SiteMapPro vider or Role2SiteMapPro vider depending on the user
    role.

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]




    "John Devlon" <Johndevlon@hot mail.comwrote in message
    news:OJ6dnawuCo igx57VnZ2dneKdn ZydnZ2d@dommel. com...
    Hi,
    >
    I've created a small application with some user-authentication and roles.
    >
    I would like to show/hide some navigation parts based on the users role.
    >
    Could someone please tell me what the best solution is?
    >
    Do I have to create different pages for each role and check the users
    role when logged in?
    >
    Thanx
    >
    Kind regards
    >
    John
    >

    Comment

    • Cowboy \(Gregory A. Beamer\)

      #3
      Re: Authentication and user based content

      There are two good solutions here (which can be combined).

      The first is to set up roles in the sitemap file. You have to set roles at
      all levels for this to work (not sure why), but roles="*" is valid.

      If you set up the SiteMap Provider to use the security trimmings, you will
      end up with it respecting security in web.config files at different levels.
      Set up your secure bits deeper (in folders) and set a web.config that only
      allows specified roles. With security trimmings on, it will not allow the
      menu to see the pages if the user is not in role(s).

      So, here it is:

      1. Most secure: Set web.configs with proper security and turn security
      trimmings on in the main web.config under the SiteMap provider
      2. Can work in most situations: Add roles to sitemap file

      One caveat:
      Have to use the Microsoft Membership bits, even if a custom provider, unless
      you want to build the entire security model yourself.

      --
      Gregory A. Beamer
      MVP, MCP: +I, SE, SD, DBA

      Subscribe to my blog


      or just read it:


      *************** *************** *************** ****
      | Think outside the box!
      |
      *************** *************** *************** ****
      "John Devlon" <Johndevlon@hot mail.comwrote in message
      news:OJ6dnawuCo igx57VnZ2dneKdn ZydnZ2d@dommel. com...
      Hi,
      >
      I've created a small application with some user-authentication and roles.
      >
      I would like to show/hide some navigation parts based on the users role.
      >
      Could someone please tell me what the best solution is?
      >
      Do I have to create different pages for each role and check the users
      role when logged in?
      >
      Thanx
      >
      Kind regards
      >
      John
      >

      Comment

      • John Devlon

        #4
        Re: Authentication and user based content

        Thanx for your respons....

        However, I think it's not something I can use...

        I've created a navigation system with pictures and placed them in a
        table....
        Only some rows have to be shown with each role...

        Can I show/hide elements like tables and pictures depending on the role?

        Thanx

        John





        "Eliyahu Goldin" <REMOVEALLCAPIT ALSeEgGoldDinN@ mMvVpPsS.orgsch reef in
        bericht news:eW67QVjnIH A.5820@TK2MSFTN GP04.phx.gbl...
        You can use different sitemaps for different roles.
        >
        If you have 2 providers in the web.config
        >
        <siteMap enabled="true">
        <providers>
        <add name="Role1Site MapProvider" description="Si teMap for role 1."
        type="System.We b.XmlSiteMapPro vider"
        siteMapFile="Ro les/Role1/Role1.sitemap" />
        <add name="Role2Site MapProvider" description="Si teMap for role 2."
        type="System.We b.XmlSiteMapPro vider"
        siteMapFile="Ro les/Role2/Role2.sitemap" />
        </providers>
        </siteMap>
        >
        you can set SiteMapProvider property for navigation controls in the code
        to either Role1SiteMapPro vider or Role2SiteMapPro vider depending on the
        user role.
        >
        --
        Eliyahu Goldin,
        Software Developer
        Microsoft MVP [ASP.NET]


        >
        >
        "John Devlon" <Johndevlon@hot mail.comwrote in message
        news:OJ6dnawuCo igx57VnZ2dneKdn ZydnZ2d@dommel. com...
        >Hi,
        >>
        >I've created a small application with some user-authentication and roles.
        >>
        >I would like to show/hide some navigation parts based on the users role.
        >>
        >Could someone please tell me what the best solution is?
        >>
        >Do I have to create different pages for each role and check the users
        >role when logged in?
        >>
        >Thanx
        >>
        >Kind regards
        >>
        >John
        >>
        >
        >

        Comment

        • Eliyahu Goldin

          #5
          Re: Authentication and user based content

          You can always check what is the role for the current user and set visual
          properties for your controls accordingly.

          --
          Eliyahu Goldin,
          Software Developer
          Microsoft MVP [ASP.NET]




          "John Devlon" <Johndevlon@hot mail.comwrote in message
          news:8jKMj.2357 8$VC1.13410@new sfe10.ams2...
          Thanx for your respons....
          >
          However, I think it's not something I can use...
          >
          I've created a navigation system with pictures and placed them in a
          table....
          Only some rows have to be shown with each role...
          >
          Can I show/hide elements like tables and pictures depending on the role?
          >
          Thanx
          >
          John
          >
          >
          >
          >
          >
          "Eliyahu Goldin" <REMOVEALLCAPIT ALSeEgGoldDinN@ mMvVpPsS.orgsch reef in
          bericht news:eW67QVjnIH A.5820@TK2MSFTN GP04.phx.gbl...
          >You can use different sitemaps for different roles.
          >>
          >If you have 2 providers in the web.config
          >>
          > <siteMap enabled="true">
          > <providers>
          > <add name="Role1Site MapProvider" description="Si teMap for role 1."
          >type="System.W eb.XmlSiteMapPr ovider"
          >siteMapFile="R oles/Role1/Role1.sitemap" />
          > <add name="Role2Site MapProvider" description="Si teMap for role 2."
          >type="System.W eb.XmlSiteMapPr ovider"
          >siteMapFile="R oles/Role2/Role2.sitemap" />
          > </providers>
          > </siteMap>
          >>
          >you can set SiteMapProvider property for navigation controls in the code
          >to either Role1SiteMapPro vider or Role2SiteMapPro vider depending on the
          >user role.
          >>
          >--
          >Eliyahu Goldin,
          >Software Developer
          >Microsoft MVP [ASP.NET]
          >http://msmvps.com/blogs/egoldin
          >http://usableasp.net
          >>
          >>
          >"John Devlon" <Johndevlon@hot mail.comwrote in message
          >news:OJ6dnawuC oigx57VnZ2dneKd nZydnZ2d@dommel .com...
          >>Hi,
          >>>
          >>I've created a small application with some user-authentication and
          >>roles.
          >>>
          >>I would like to show/hide some navigation parts based on the users role.
          >>>
          >>Could someone please tell me what the best solution is?
          >>>
          >>Do I have to create different pages for each role and check the users
          >>role when logged in?
          >>>
          >>Thanx
          >>>
          >>Kind regards
          >>>
          >>John
          >>>
          >>
          >>
          >
          >

          Comment

          Working...