I would not expect a thread that has a different identity to βinheritβ permissions from the process identifier.
Just to make sure I did an impersonation test. Using the sample WindowsIdentity.Impersonate here, I ran the following code in another thread.
WindowsIdentity newId = new WindowsIdentity(safeTokenHandle.DangerousGetHandle()); Thread.CurrentPrincipal = new WindowsPrincipal(newId); string foo = System.IO.File.ReadAllText (@"test.txt"); Console.WriteLine(foo); )); WindowsIdentity newId = new WindowsIdentity(safeTokenHandle.DangerousGetHandle()); Thread.CurrentPrincipal = new WindowsPrincipal(newId); string foo = System.IO.File.ReadAllText (@"test.txt"); Console.WriteLine(foo);
Despite the fact that the process identifier has the right to read test.txt, if the newID does not work.
source share