Security principals

Jul 3, 2013 at 3:57 AM
Markus,
When the user logs in and gets a response from the database, I create a local user Principal and save it in Thread.CurrentPrincipal (per the example built by the framework when I created the project. If I check it after the login is complete, it seems to be fine.

But when a new view model is called up, the value for Thread.CurrentPrincipal is null.

Changing it to store the principal in an instance of AppDomain.CurrentDomain seems to have fixed the problem.

I just wanted to check in case I fixed the symptom, not the problem.

Thanks,

Fletcher
Coordinator
Jul 8, 2013 at 1:15 AM
I'd need to check what the default template code is that gets generated, but something like this should do the trick:
AppDomain.CurrentDomain.SetThreadPrincipal(principal);
Markus
Coordinator
Jul 8, 2013 at 1:16 AM
Actually, I just checked. This is the default code that is in there, which should work:
AppDomain.CurrentDomain.SetThreadPrincipal(new CODEFrameworkPrincipal(new CODEFrameworkUser(UserName)));
Markus
Jul 8, 2013 at 11:54 PM
Markus,

I didn't check, but believe you. It may be that it has been fixed and I only see it because that section of code was written a build or 2 ago. Since I fixed it the right way, not a problem.

Thanks,

Fletcher