Hi. I have a WPF-Application. There i start a seperate Thread, when the application starts. Now, I should set a other User for this Thread then the Application has. I have seen, that this works for non-WPF-Application. But in WPF-Application, the User (principal) will be stored in the ApplicationContext for WPF and always this is used. Is there a way, that I can set a other User for one thread in a WPF-Application?
Thank you.
Best Regards, Thomas
Hi.
I have now tried something. When I change GetUser() of Csla.Xaml.ApplicationContextManager to this:
public IPrincipal GetUser()
{
IPrincipal current;
if (System.Windows.Application.Current != null)
{
if (_principal == null)
{
if (ApplicationContext.AuthenticationType != "Windows")
_principal = new Csla.Security.UnauthenticatedPrincipal();
else
_principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
}
if (Thread.CurrentPrincipal is Csla.Security.CslaPrincipal && !(Thread.CurrentPrincipal is Csla.Security.UnauthenticatedPrincipal)) {
current = Thread.CurrentPrincipal;
} else {
current = _principal;
}
}
else
current = Thread.CurrentPrincipal;
return current;
}
It is working for me. Now my question: Does I have problems which I don't see now, with this solution? Can this solution work general or would it be possible to change Csla, that I can change this logic from outside - for example with an Event?
Best Regards, Thomas
Copyright (c) Marimer LLC