I’m working on a project where I need to open a winform from a web service. I am not sure what the winform is opening as(my user account, a system account, aspnet, etc.) and I want to know if there is a way to check when I execute the following code:
namespace.Form2 form2 = new namespace.Form2();
System.Windows.Forms.Application.Run(form2);
I would prefer a way to see what account is being used when I call Application.Run, but if anyone knows which account is used by default that would be helpful as well.
Something as simple as this would suffice :
MessageBox.Show("form2 running as: " + Thread.CurrentPrincipal.Identity.Name);
I think when I call Application.Run it starts a new process though, and doesn’t run under this same identity. Credential passing is crucial to making this work, so it has to run as the right account (the same one that appears when I run the above code).
Your understanding is incorrect.
Application.Runis an ordinary managed function.It doesn’t change identities or start processes; it just runs an infinite loop.