title: Failed to impersonate domain user via C#
body: <p>I am trying to impersonate remote admin user so that i can perform modifications on the files present on remote Linux machine. But i get error message as Access to the path is denied.
  However this thing manually i am able to do via putty using command : </p>
  
  <pre><code>sudo -S -u wtsnqa rm /path-to-file/
  </code></pre>
  
  <p>Any help is worth appreciable.</p>
  
  <p>My code :</p>
  
  <pre><code>SessionOptions sessionOptions = new SessionOptions
  {
      Protocol = Protocol.Sftp,
      HostName = "sj1slm612",
      UserName = "userid",
      Password = "password",
      SshHostKeyFingerprint = "ssh-rsa 2048 fa:e9:58:24:1b:41:a3:15:63:0d:c0:72:41:5d:51:7a"
  };
  
  using (Session session = new Session())
  {
      // Connect
      session.Open(sessionOptions);
  
      // Performing removing files from remote server via impersonation.......
  
      AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.WindowsPrincipal);
      using (WindowsIdentity Authorized_user = new WindowsIdentity("wtsnqa"))
      {
          using (WindowsImpersonationContext context = Authorized_user.Impersonate())
          {              
  
              File.Delete(@"\\sj1slm612\apps\instances\express_13000\configuration\standalone-full.xml");
              File.Delete(@"\\sj1slm612\apps\instances\query_13100\configuration\standalone-full.xml");
              File.Delete(@"\\sj1slm612\apps\instances\wppapi_13200\configuration\standalone-full.xml");
              File.Delete(@"\\sj1slm612\apps\instances\wppgui_13300\configuration\standalone-full.xml");
  
              Console.WriteLine("All config files removed from sj1slm612");
              Console.ReadLine();
              context.Undo();
          }
  </code></pre>