简体   繁体   English

如何以用户身份启动进程然后在c#ASP.NET中提升

[英]how to start a process as user then elevate in c# ASP.NET

I am working on a web application that install software on a server. 我正在使用在服务器上安装软件的Web应用程序。

I can run the install by hand if I log in a user that is apart of a specific group then run install msi as administrator. 如果登录到特定组之外的用户,则可以手动运行安装,然后以管理员身份运行install msi。

This specific group is apart of the local administrators group. 该特定组属于本地管理员组。

My app pool is running as Network_Service. 我的应用程序池作为Network_Service运行。

Do I impersonate then use the runAs verb? 我要模仿然后使用runAs动词吗? but then I need to know the u/p as user and u/p of Administrator .. I think 但是然后我需要知道u / p作为用户和u / p是Administrator ..我认为

I am using the System.Diagnostics.Process classes. 我正在使用System.Diagnostics.Process类。

       System.Diagnostics.ProcessStartInfo oInfo = new System.Diagnostics.ProcessStartInfo(str);
        oInfo.UseShellExecute = false;
        oInfo.ErrorDialog = false;
        oInfo.CreateNoWindow = false;
        oInfo.RedirectStandardOutput = true;


        Process p = System.Diagnostics.Process.Start(oInfo);

        System.IO.StreamReader oReader2 = p.StandardOutput;
        string sRes = oReader2.ReadToEnd();
        oReader2.Close();
    return sRes;

您需要将UserNamePassword属性设置为Administrator帐户的登录凭据。

You can't change the user context of a running process later on. 您以后将无法更改正在运行的进程的用户上下文。 I suggest u use windows authentication and impersonation to be sure the web request is executed as the authenticated user and besides that you don't have to care about the user credentials. 我建议您使用Windows身份验证和模拟来确保Web请求以经过身份验证的用户身份执行,此外,您不必关心用户凭据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM