The user fires an event, so the thread is in the context of the specified user. I iterate over all connected users and want to send them to this event, but I want to use classic authorization to determine if they should receive the event. The problem is that the main thread, etc. Located in the context of the user who triggered the event.
I search for the personify thread, and then log in. I found this article on it
http://msdn.microsoft.com/en-us/library/ff647248.aspx#ImpersonationDelegation5
using System.Security.Principal;
…
WindowsIdentity wi = new WindowsIdentity(userName@fullyqualifieddomainName);
WindowsImpersonationContext ctx = null;
try
{
ctx = wi.Impersonate();
catch
{
}
finally
{
ctx.Undo();
}
After the ctx = wi.Impersonate();thread is still in the context of the calling user, what am I doing wrong?
Update
I want to run this code as a different user
provider = AuthorizationFactory.GetAuthorizationProvider();
provider.Authorize(Thread.CurrentPrincipal, Rule)
, ,
http://andersmalmgren.com/2014/06/12/client-server-event-aggregation-with-role-authorization/