473,241 Members | 1,850 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

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
Jun 27 '08 #1
4 1376
You can use different sitemaps for different roles.

If you have 2 providers in the web.config

<siteMap enabled="true">
<providers>
<add name="Role1SiteMapProvider" description="SiteMap for role 1."
type="System.Web.XmlSiteMapProvider"
siteMapFile="Roles/Role1/Role1.sitemap" />
<add name="Role2SiteMapProvider" description="SiteMap for role 2."
type="System.Web.XmlSiteMapProvider"
siteMapFile="Roles/Role2/Role2.sitemap" />
</providers>
</siteMap>

you can set SiteMapProvider property for navigation controls in the code to
either Role1SiteMapProvider or Role2SiteMapProvider depending on the user
role.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"John Devlon" <Jo********@hotmail.comwrote in message
news:OJ******************************@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

Jun 27 '08 #2
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
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
"John Devlon" <Jo********@hotmail.comwrote in message
news:OJ******************************@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

Jun 27 '08 #3
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" <RE**************************@mMvVpPsS.orgschree f in
bericht news:eW**************@TK2MSFTNGP04.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="Role1SiteMapProvider" description="SiteMap for role 1."
type="System.Web.XmlSiteMapProvider"
siteMapFile="Roles/Role1/Role1.sitemap" />
<add name="Role2SiteMapProvider" description="SiteMap for role 2."
type="System.Web.XmlSiteMapProvider"
siteMapFile="Roles/Role2/Role2.sitemap" />
</providers>
</siteMap>

you can set SiteMapProvider property for navigation controls in the code
to either Role1SiteMapProvider or Role2SiteMapProvider depending on the
user role.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"John Devlon" <Jo********@hotmail.comwrote in message
news:OJ******************************@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


Jun 27 '08 #4
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]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"John Devlon" <Jo********@hotmail.comwrote in message
news:8j*******************@newsfe10.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" <RE**************************@mMvVpPsS.orgschree f in
bericht news:eW**************@TK2MSFTNGP04.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="Role1SiteMapProvider" description="SiteMap for role 1."
type="System.Web.XmlSiteMapProvider"
siteMapFile="Roles/Role1/Role1.sitemap" />
<add name="Role2SiteMapProvider" description="SiteMap for role 2."
type="System.Web.XmlSiteMapProvider"
siteMapFile="Roles/Role2/Role2.sitemap" />
</providers>
</siteMap>

you can set SiteMapProvider property for navigation controls in the code
to either Role1SiteMapProvider or Role2SiteMapProvider depending on the
user role.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"John Devlon" <Jo********@hotmail.comwrote in message
news:OJ******************************@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



Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: dmcconkey | last post by:
Hi folks, I've been searching for a while and haven't found my specific question anywhere else. If this has already been asked, please accept my appologies and point me to the appropriate...
3
by: Nick | last post by:
I am working a new application...well actually a series of applications for my company. They want internal users to be able to go to a site and everything regarding security is transparent,...
1
by: Rob | last post by:
I have an ASP.NET application that uses forms-based authentication. A user wishes to be able to run multiple sessions of this application simultaneously from the user's client machine. The...
5
by: Maziar Aflatoun | last post by:
Hi everyone, I have a login .aspx page that I like to forward my users to. However, can't do it using <authorization> ..... </authorization> because I need anonymous users to use it without...
1
by: Shapper | last post by:
Hello, I am developing a web site where half of the pages are public and the other half are accessible only to registered users. The pages which are accessible only to registered users have...
11
by: xenophon | last post by:
I have a web site with forms authentication and a single logon page. I have 4 subdirectories, each that should be protected by a different username/password combination. For testing purposes, the...
1
by: Mark Olbert | last post by:
I'm building an ASPNET2 website which uses forms authentication but does not use the Microsoft-supplied membership providers (mostly because I don't want to create my own provider at this point, and...
3
by: Martin | last post by:
How does one set up basic authentication on an HttpListener? I know I need to set the HttpListener.AuthenticationSchemes to AuthenticationSchemes.Basic but then I'm unsure how and against what...
1
by: Tony Stephens | last post by:
Hi, I've created a small forms based application in c# to test a vendor's product and the web service interface that it exposes. We have deployed two instances of the vendor product one which...
5
by: Rory Becker | last post by:
Having now created a Custom MembershipProvider that seems to work correctly with my Logon and ChangePassword controls, I am, as they say, a happy bunny. The next stange is to move on to the...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.