View Single Post
Old 04-12-2008   #1 (permalink)
luke.quinane
Guest


 

Access denied while impersonating

Hi All,

I'm trying to wrap Powershell in C# for a SSH server implementation
but I am getting the following message:

Windows PowerShell terminated with the following error:
Access is denied. (Exception from HRESULT: 0x80070005
(E_ACCESSDENIED))


To start Powershell I am impersonating another user like so:

WindowsIdentity windowsIdentity = (WindowsIdentity)
identity;
windowsIdentity.Impersonate();

ProcessStartInfo psi = new ProcessStartInfo()
{
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
RedirectStandardError = true,
RedirectStandardOutput = true,
RedirectStandardInput = true,
UseShellExecute = false,
ErrorDialog = false,
WorkingDirectory = @"C:\windows
\system32\WindowsPowerShell\v1.0\",
FileName = @"C:\windows\system32\WindowsPowerShell
\v1.0\powershell.exe",
Arguments = "-i Text -NoExit -Command -"
};

_childProcess = Process.Start(psi);

Does anyone have any idea why this is not working? What sort of
permission would Powershell be requiring to start up?


Thanks in advance,


Luke