访问权限从凭据远程访问安装exe文件被拒绝 [英] Access get denied from credential remote access install exe file

查看:106
本文介绍了访问权限从凭据远程访问安装exe文件被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Access Get denied from credential remote access install exe file





捕获时捕获(Win32Exception)

错误消息>>拒绝访问。



我已将用户名,密码和域名输入StartInfo以便管理员登录。



因此用户可以通过单击按钮自动安装exe.file。



有什么建议可以解决这个问题吗?需要帮助!!!



我尝试过:





Capture at catch (Win32Exception)
Error message >> Access Denied.

I already put in the the username, password, and domain to StartInfo for admin login.

So the user can auto install the exe.file with single button click.

Any recommendation to solve this problem ? Need HELP !!!

What I have tried:

<pre lang="c#">

public static void GiveLogOnAsAServiceRights(string path,string username,string password,string domain,string computer,string args)

{

尝试

{

string tempPathForExe =//这是来自服务器路径(我关闭它);

string ntRightsTempFileName =//这是安装程序;

string fullNtRightsTempPath = Path.Combine(tempPathForExe,ntRightsTempFileName);

//系统。 IO.Directory.CreateDirectory(tempPathForExe);





流程objProcess = new Process();

objProcess .StartInfo.Arguments = @\\+ computer + - u+ domain +\\+ username + - p+ password + - i -d -h+ - accepteula +路径+ + args;

objProcess.StartInfo.RedirectStandardOutput = true;

if(!string.IsNullOrEmpty(username))

objProcess.StartInfo.UserName = username;

if(!string.IsNullOrEmpty(password))

{

objProcess.StartInfo.Password = new System.Security.SecureString ();

char [] passwordChars = password.ToCharArray();

foreach(charc in passwordChars)

objProcess.StartInfo.Password .AppendChar(c);

}

objProcess.StartInfo.Domain =penang;

objProcess.StartInfo.RedirectStandardError = true;

objProcess.StartInfo.RedirectStandardInput = true;

objProcess.StartInfo.CreateNoWindow = true;

objProcess.StartInfo.UseShellExecute = false;

objProcess.StartInfo.Verb =runas;



objProcess.StartInfo.FileName = fullNtRightsTempPath;

objProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;





// string connectionString = string.Empty;



//在接下来的两个函数中,应该弹出一个控制台并告诉我它在做什么......但它没有t $ / b
objProcess.Start();

objProcess.WaitForExit();



if(objProcess.HasExited )

{

//System.IO.File.Delete(fullNtRightsTempPath);

objProcess.Close();

返回;

}



}

catch(Win32Exception w32E)

{

//这个过程没有开始。



Console.WriteLine(w32E);

}

}



protected void Button1_Click (对象发送者,EventArgs e)

{

GiveLogOnAsAServiceRights(this is path dicratory,ansontay,1232312313,malaysia,HostnameAndService,) ; //计算机名称(HostnameAndService)

}

public static void GiveLogOnAsAServiceRights(string path, string username, string password, string domain, string computer, string args)
{
try
{
string tempPathForExe = " // This is from server path (i close it)";
string ntRightsTempFileName = "//this is the installer";
string fullNtRightsTempPath = Path.Combine(tempPathForExe, ntRightsTempFileName);
//System.IO.Directory.CreateDirectory(tempPathForExe);


Process objProcess = new Process();
objProcess.StartInfo.Arguments = @"\\" + computer + " -u " + domain + "\\" + username + " -p " + password + " -i -d -h " + "-accepteula " + path + " " + args;
objProcess.StartInfo.RedirectStandardOutput = true;
if (!string.IsNullOrEmpty(username))
objProcess.StartInfo.UserName = username;
if (!string.IsNullOrEmpty(password))
{
objProcess.StartInfo.Password = new System.Security.SecureString();
char[] passwordChars = password.ToCharArray();
foreach (char c in passwordChars)
objProcess.StartInfo.Password.AppendChar(c);
}
objProcess.StartInfo.Domain = "penang";
objProcess.StartInfo.RedirectStandardError = true;
objProcess.StartInfo.RedirectStandardInput = true;
objProcess.StartInfo.CreateNoWindow = true;
objProcess.StartInfo.UseShellExecute = false;
objProcess.StartInfo.Verb = "runas";

objProcess.StartInfo.FileName = fullNtRightsTempPath;
objProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;


//string connectionString = string.Empty;

//During these next two functions, a console is supposed to pop up and tell me what it is doing... but it doesn't
objProcess.Start();
objProcess.WaitForExit();

if (objProcess.HasExited)
{
//System.IO.File.Delete(fullNtRightsTempPath);
objProcess.Close();
return;
}

}
catch (Win32Exception w32E)
{
// The process didn't start.

Console.WriteLine(w32E);
}
}

protected void Button1_Click(object sender, EventArgs e)
{
GiveLogOnAsAServiceRights("this is path dicratory", "ansontay", "1232312313", "malaysia", HostnameAndService, ""); // Machine name (HostnameAndService)
}

推荐答案

您正在获取AccessDenied,因为您的ASP.NET代码在不运行的帐户下运行没有工作站的管理员权限,也不应该有。



当然,你给ProcessStartInfo提供了运行流程的帐户凭据,但是这不会给你在远程工作站上启动进程的权限。



哦,还有一件事。远程启动的进程永远不会在登录到远程计算机的用户的桌面上可见。这是一个严重的安全风险,是被禁止的。如果您启动的进程显示任何类型的UI(包括仅控制台窗口),则登录到计算机的任何人都无法看到它。如果进程正在等待输入,它将永远不会收到任何。
You're getting AccessDenied because the account your ASP.NET code is running under doesn't have admin permissions to the workstations, nor should it ever.

Sure, you're giving the ProcessStartInfo the credentials for the account to run the process as, but that does NOT give you the permissions to launch the process on the remote workstation.

Oh, and another thing. A remotely launched process will NEVER be visible on the desktop of the user logged into the remote machine. This is a severe security risk and is forbidden. If the process you launch shows any kind of UI at all, including just a console window, it will NOT be visible to anyone logged into the machine. If the process is waiting for input, it will never receive any.


这篇关于访问权限从凭据远程访问安装exe文件被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆