Line: int CurrentUserLevel = ((XEIdentity)Thread.CurrentPrincipal.Identity).UserLevel;
How can we go around this? I will appreciate any feedback
Thanks
If you are using Windows authentication then you should be using a WindowsIdentity, not a custom identity.
If you are using a custom identity then you need to set the current principal on every page request (in global.asax). See Chapter 10 for details.
If you are trying to do both, then you still need to set the current principal on every page request, you'll just pull the username from the WindowsIdentity when creating your custom principal.
In any case, I recommend you use Csla.ApplicationContext.User rather than directly interacting with either HttpContext.Current.User or System.Threading.Thread.CurrentPrincipal, because (as discussed in the book) ApplicationContext.User addresses some scenarios where either of those other two locations may be incorrect at times.
Copyright (c) Marimer LLC