Windows Vista Forums

Access denied while impersonating
  1. #1


    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



      My System SpecsSystem Spec

  2. #2


    RichS [MVP] Guest

    RE: Access denied while impersonating

    I'm curious as to why you are starting PowerShell as a new process rather
    than hosting it within the application as shown here

    http://msdn2.microsoft.com/en-us/lib...42(VS.85).aspx

    --
    Richard Siddaway
    All scripts are supplied "as is" and with no warranty
    PowerShell MVP
    Blog: http://richardsiddaway.spaces.live.com/
    PowerShell User Group: http://www.get-psuguk.org.uk


    "luke.quinane@xxxxxx" wrote:

    > 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
    >

      My System SpecsSystem Spec

Access denied while impersonating problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
can't open access control editor. Access is denied pjjppj General Discussion 3 20 Oct 2008
Access Denied, Access Denied- like a broken record! Sam Vista General 7 25 Apr 2008
When standard users access Vista registry remotely, Access Denied Gayle Vista account administration 1 10 Oct 2007
Access Denied trying to access Vista PC Ron Vista networking & sharing 7 30 Sep 2007
Access is denied message when trying to access a remote printer MarkC Vista print fax & scan 1 08 Mar 2007