Last post Jun 29, 2009 11:01 AM by VavrinaL
Jun 25, 2009 03:37 AM|VavrinaL|LINK
How can I scaffold tables according to logged user...? I need a table to be visible for an administrator but not for a customer.
Any help would be appreciated. Thanks.
Jun 25, 2009 04:19 AM|integrasol|LINK
Are you using Dynamic Data? If so, you might want to customize the page templates, or create new ones, to check the value of the System.Web.HttpContext.Current.User and look at role based security. I don't know your setup, so I'm just throwing out ideas
here. Another thing you may want to look at, in addition to securing the individual pages, is to security trim the menus to only display the menus to which the current user have access. The Menu control can be used with a SiteMapDataSource and with a sitemap
XML file you can add roles to the individual menu items.
Jun 25, 2009 04:32 AM|VavrinaL|LINK
Thanks a lot for your ideas.
As you guessed I use dynamic data. My idea was to use the same pages for all users and to modify scaffolding attributes at runtime. Something like ScaffoldTable = Roles.IsUserInRole("Administrators") but I do not how to achieve that... Setting scaffolding
attributes statically via partial classes <ScaffoldTable(True)> is not an issue... but dynamic... ;)
Thanks a lot.
Jun 25, 2009 04:53 AM|integrasol|LINK
Well, the data annotations, including the ScaffoldTable attribute are really only used when compiling and inspecting the assembly, so dynamically setting it is not an option. I would modify the page templates or create a new set if I were you, although that
does create a "little" more work. :-) I'm sure there are other options, but AFAIK that will require even more work.
Jun 25, 2009 06:36 AM|sjnaughton|LINK
Have a look at this sample by one of the ASP.Net team on codeplex here
Dynamic Data Samples and in particular this sample here:
Jun 29, 2009 11:01 AM|VavrinaL|LINK
Ok, it seems to solve my initial issue. Thanks a lot.
One further question: Is there any way to set a record filter according to a logged user. I need to show to the logged users different set of records from one table.