Context.User CustomPrincipal Object problemer.
Hejsa, jeg har lavet et custom principal objekt, så jeg har et custom objekt for hver rolle der findes i systemet. Problemet er bare at jeg få adgang til de funktioner der er i objektet fordi den Context.User er erklæret med Interfacet Iprincipal, som har ganske få funktioner.Følgende uddrag af kode sørger for oprettelse af objektet i global.asax's Application_AuthenticateRequest funktionen:
**********************************************************
...
string[] roles = authTicket.UserData.Split(new char[]{'|'});
//To extract the TYPE, its importen to load the Assembly, where
//the Roles Classes is placed
Assembly a = Assembly.Load("Roles");
//Note that a persons essential Role is at Place 0 in the Role String Array
Type t = a.GetType("Roles." + roles[0].ToString(),true,true);
// Create an Identity object
FormsIdentity id = new FormsIdentity( authTicket );
//Preperation of arguments to constructor in Roles Costum
object[] args = {id ,roles};
//Create the costum SAM principal object
//by using late binding
Iprincipal principal = (Iprincipal)Activator.CreateInstance(t,args);
// This principal will flow throughout the request.
// Attach the new principal object to the current HttpContext
//object
Context.User = principal;
***********************************************************
Problemet er som sagt at når jeg så eksempelvis vil bruge nogle af mine custom funktioner, så har jeg ikke adgang til dem. I min page load vil jeg gerne kunne skrive:
Submenu1.TabItems = Context.User.MENU;
Det giver selvfølgelig en compiler fejl, MENU ikke er defineret i IPrincipal. Jeg kan heller ikke Rolle typen Iprincipal objektet så jeg kan ikke typecaste Useren til den rigtige rolle, så jeg er lidt på bar bund. Hjælp.
