views:

27

answers:

2

I'm using forms authentication in my C# based web site, with the authentication defined in web.config files in the various folders/sub-folders. I want to write a generic administration menu system, that lists all of the admin pages that the use is authorized to open. As I add pages, I want them to automatically show up in the menu. So...

I need to obtain a list/collection of all pages that the active user is authorized to open. Is this possible in ASP.Net 3.5?

I assume that ASP.Net has an internal collection of pages somewhere, together with their required roles (as it must check somewhere when you attempt to open a page)?

+1  A: 

I would suggest looking into using a sitemap (in ASP.Net, web.SiteMap). Then you can use the SiteMap as a datasource (as well as define roles, etc for each page).

Gabriel McAdams
This sounds like a great idea. Still requires you to manage/update the sitemap dynamically somehow, but much easier than coding it all from scratch.
Bryan
This sounds perfect! Thanks Gabriel.
Milky Joe
A: 

You assume incorrectly... There is no internal listing of these pages, only the file system. Access is checked on a file-by-file basis when ASP.NET attempts to open the page.

To do what you're looking for, you'll have to code it up yourself using System.IO and getting the authorization settings from web.config.

Bryan
I agree, forms auth is specified on a per-page or per-directory basis either in a sitemap or web.config. You could write custom IO code to parse out this information.
Daniel Coffman