Referring to THIS QUESTION I was able to execute some code as different user. Now I'm trying to execute a piece of code as a user with administrator privileges and I get a missing file error. The code is this:
using (new Impersonator("domainAdmin", "DOMAIN", "myStup1dPa$$w0rd"))
{
GetXAApplicationByName apps = new GetXAApplicationByName();
apps.BrowserName = new string[] { "*" };
IEnumerable<XAApplication> result = CitrixRunspaceFactory.DefaultRunspace.ExecuteCommand(apps);
// other code...
}
The error is thrown at last reported line, the one starting with IEnumerable<XAApplication>
and is:
FileNotFoundException not handled C:\Windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll
I don't report code for Impersonator
class, the basic schema is reported on linked question (and it worked also in other applications).
Am I missing something?