我想从 IP 为:sj1slm612 的远程机器上删除一个配置文件。现在的问题是我没有对该远程机器的完全修改权限,所以我使用模拟技术来做到这一点。通常,当我通过 putty 连接到这台远程机器时,我使用“sudo”。所以我的问题是下面的代码能解决我的问题吗?谢谢。
我的代码:
AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.WindowsPrincipal);
using (WindowsIdentity Authorized_user = new WindowsIdentity("sj1slm612\\wtsnqa", "password"))
{
using (WindowsImpersonationContext context = Authorized_user.Impersonate())
{
File.Delete(@"/apps/instances/express_13000/configuration/standalone-full.xml");
File.Delete(@"/apps/instances/query_13100/configuration/standalone-full.xml");
File.Delete(@"/apps/instances/wppapi_13200/configuration/standalone-full.xml");
File.Delete(@"/apps/instances/wppgui_13300/configuration/standalone-full.xml");
Console.WriteLine("All config files removed from sj1slm612");
Console.ReadLine();