Welcome to Dream.In.Code
Getting Help is Easy!

Join 105,764 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,627 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Dynamic navigation

 
Reply to this topicStart new topic

Dynamic navigation

PsychoCoder
post 7 May, 2008 - 03:18 PM
Post #1


DIC.Rules == true;

Group Icon
Joined: 26 Jul, 2007
Posts: 7,030



Thanked 47 times

Dream Kudos: 7600

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, GDI

My Contributions


In the screenshot below is the navigation I am attempting to use for the entire administrative console for our site. It uses a SiteMap and a SiteMapDataSource to load the navigation from the Sitemap XML file. This is just the navigation for this section of the site, what Im wanting to do is make the whole admin site like this, only have the SiteMap and SiteMapDataSource be dynamic based on the logged in users access rights.

Ive done quite a bit of Googling for this and havent really found anything useful, or anything to get me started down the right path. Has anyone else done anything like this, if so how did you accomplish it?

Attached Image
User is online!Profile CardPM

Go to the top of the page


jayman9
post 7 May, 2008 - 04:20 PM
Post #2


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,241



Thanked 21 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


Well I can't say that I have done exactly that using SiteMap and SiteMapDataSource (haven't used those objects yet). But at work, depending on who the user is that is logged in will determine which navigation links are visible.

And I am not sure completely what you are looking for in the way of help here. But we use Context.User.IsInRole("A role"), to determine which user is logged in and based on the result will load navigation and other controls appropriately.

Is this kind of what you are looking for or are you looking for something more specific?
User is offlineProfile CardPM

Go to the top of the page

thor78
post 7 May, 2008 - 05:34 PM
Post #3


D.I.C Head

Group Icon
Joined: 6 May, 2008
Posts: 104



Dream Kudos: 50
My Contributions


I dont quite remember the exact term for it, but you have to edit your web.config as well as your sitemap. I think the term is security trimming, it is based on the roles indicated in the role providers.
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 8 May, 2008 - 02:08 PM
Post #4


DIC.Rules == true;

Group Icon
Joined: 26 Jul, 2007
Posts: 7,030



Thanked 47 times

Dream Kudos: 7600

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, GDI

My Contributions


Jay,

Once the user logs in there are 4 main access areas, Users, Reports, Payments and Accounts. They are stored as a pipe delimited string, say a user has access to accounts and reports only their string would look like ACC|RPT., my accessLevel string would look like USR|RPT|ACC|PMT meaning I have access to everything. What I'm trying to come up with is a solution to load the proper SiteMap for the user logged in, or a better solution for displaying only the navigation the logged in user has access to. Hope this makes more sense than my original post smile.gif
User is online!Profile CardPM

Go to the top of the page

skaoth
post 8 May, 2008 - 02:31 PM
Post #5


D.I.C Regular

Group Icon
Joined: 7 Nov, 2007
Posts: 316



Thanked 5 times

Dream Kudos: 100
My Contributions


I've done something like this. The site I was working on had an admin section that would populate an admin section only for those with proper privileges.

To get this to work I had to create a custom sql sitemap provider and drop the whole xml sitemap altogether.
Here a link on that. http://weblogs.asp.net/scottgu/archive/200.../11/435108.aspx

What I did then was move the sitemap content into a DB table. I would then based on the
users permissions/account type, I would only bring back the records for the sitemap that
the user is allowed to see.

Once I got the items for the needed menu I would create a tree of sitemapnode objects
that represent the the sitemap that will be displayed to the user. The root of the tree
would then be bound to the actual sitemap control

Hope that makes sense. If not I'll try to see if I can find the resources I used to do this.

For the most part I got this working correctly. I only had issue when trying to dynamically add/remove
items to the menu and refreshing it properly


Edit:
The article can actually be found here:
http://msdn.microsoft.com/en-us/magazine/cc163657.aspx

This post has been edited by skaoth: 8 May, 2008 - 02:43 PM
User is offlineProfile CardPM

Go to the top of the page

jayman9
post 8 May, 2008 - 02:53 PM
Post #6


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,241



Thanked 21 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


Alright, I understand what you are trying to do. You will basically create rules that will determine based on the Role, which navigation links are visible. Each user will be assigned to a Role, so you are going to create 4 Roles.

The following Walkthrough should give you are pretty good idea how to do it.
Filtering Site-Map Nodes Based on Security Roles
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/21/08 02:18PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month