作者ljhgc (是向往亦或逃避)
看板C_Sharp
标题[问题] 远端安装
时间Wed Aug 11 19:48:11 2010
小弟现在用IIS架设一个web
其中有一个页面是可以选择要下载哪些东西(server会列出来)
(要进入此页面时,会跳出windows验证,必需输入可用在登录server的windows帐密)
下载後是存放在server的某个资料夹底下(不在web底下)
下载完可以选择要安装哪个
现在卡在,当执行安装档时,总是会用ASPNET的身分去跑
这样就变得没有权限可以作安装的动作了
以下是我的code
=========================
public static WindowsIdentity gwinId;
public static WindowsImpersonationContext cix;
protected void Page_Load(object sender, EventArgs e)
{
gwinId = (WindowsIdentity)HttpContext.Current.User.Identity;
try
{
cix = gwinId.Impersonate();
}
catch
{
//Impersonate() fail
}
}
void btn_Install_Click(object sender, EventArgs e)
{
string argIn = "/k cd \"" + fileFolderPath + "\"";
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.Arguments = argIn;
p.Start();
p.StandardInput.WriteLine("filename");
p.StandardInput.WriteLine("exit");
p.WaitForExit();
p.Close();
}
====================================================================
小弟我其实对C#不熟,应该说是根本没接触过
是这几天某些因素,不得不用C#
请问有大大能替我解惑吗?
为什麽在执行cmd.exe或安装档时,总是会用ASPNET去执行
而不是使用一开始页面load时验证过的帐户呢?
谢谢!!!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.120.37.166
※ 编辑: ljhgc 来自: 59.120.37.166 (08/16 13:22)
2F:→ ljhgc:谢谢S大的回应,不过连结里的方法都不是我要的 08/16 13:22
3F:→ ljhgc:方法一,需要在Web.config里写入帐密,这在安全上有隐忧 08/16 13:22
4F:→ ljhgc:方法二,我并不知道user会以哪个帐密登入,且我也不知道 08/16 13:22
5F:→ ljhgc:server端的帐密 08/16 13:22
6F:→ ljhgc:我这网页在user要开启时,便会先跳出window验证了, 08/16 13:22
7F:→ ljhgc:验证过了网页才会开启,我的code我有在中间去监看, 08/16 13:22
8F:→ ljhgc:确实有模拟并取得user输入的window account, 08/16 13:22
9F:→ ljhgc:可是不晓得为什麽我要去run别只程式时,却会以ASP.NET执行 08/16 13:23