Hi.
I'm following the PTTracker model of Identities, I'm trying to add an Integer property called adminID to the identitiy to use in my code behind of my page. I've added it to my Fetch method and have made (what I think) are the appropriate changes to the business methods (declaration and property).
However in my app I cannot access it using User.Identity.adminID like I can User.Identity.Name....is there something I need to do in my membershipprovider?
Ryan
The Interface only exposes certain values.
Try casting User.Identity to your specific type.
Then you should be able to see your custom properties.
Joe
I think there is something more to this....trying to cast I get an error:
Unable to cast object of type 'System.Web.Security.FormsIdentity' to type 'CslaProject.Library.AdminSecurity.AdminIdentity'.
Something seems off...like my AdminPrincipal class needs to do something else...
Ryan
Got it...
Here's the thread that sent me down the right road
Ok so this works but now in order to make it globally available is it ok to make this a public property of my Master Page and then access the property from my pages?
Yes, though I usually do it with a static class or Module in my business layer:
public static class Security
{
public static MyPrincipal User()
{
return (MyPrincipal)Csla.ApplicationContext.User;
}
}
Then you can use Security.User anywhere in your app and you always get the right type automatically.
Copyright (c) Marimer LLC