473,322 Members | 1,403 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,322 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 1379
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.