I have created a custom Identity class and extended the Csla.Security.BusinessPrincipalBase classes in my BO library in order to implement an IsPermitted method. This is something I've done with previous applications and it has performed as expected; however, it refuses to work at all in my current application. The message I receive when I check IsPermitted is:
Cannot cast 'System.Threading.Thread.CurrentPrincipal' (which has an actual type of 'System.Security.Principal.GenericPrincipal') to 'Csla.Security.BusinessPrincipalBase'
In my extended BusinessPrincipalBase, IsPermitted is coded as follows:
public bool IsPermitted(string Department, string Role)
{
RTPIdentity identity = (RTPIdentity)this.Identity;
return identity.IsPermitted(Department, Role);
}
Identity is obtained via:
internal static RTPIdentity GetIdentity(string username, string password)
{
return DataPortal.Fetch<RTPIdentity>(new Criteria(username, password));
}
This has me thoroughly confused since it's worked without a hitch in my other applications. Does anyone have an idea why this is occurring?
I neglected to include a few things. First of all, I have a helper function in my UI layer as follows:
private bool IsPermitted(string department, string role)
{
return ((Csla.Security.BusinessPrincipalBase)(System.Threading.Thread.CurrentPrincipal)).IsPermitted(department, role);
}
It is when I try to retrieve IsPermitted in the return statement that the problem occurs.
Copyright (c) Marimer LLC