从ASP.NET应用程序重新启动服务器时,程序池是根据本地系统或LocalService帐户运行 [英] Restart Server from ASP.NET application when AppPool is ran under LocalSystem or LocalService account
问题描述
是否有可能从由本地系统或LocalService帐户托管ASP.NET应用程序重新启动服务器?当我创建自定义管理帐户,这是工作,把程序池该帐户下运行:
Is it possible to restart server from ASP.NET application that is hosted by LocalSystem or LocalService account? This is working when I create custom administrative account and put AppPool to run under that account:
Process.Start("shutdown", "/r /d 4:1 /t 10");
不过,我不希望有定制的帐户(因为密码到期,需要更新所有AppPools当用户密码被更改? - 我需要维护多台服务器)
However, I don't want to have custom accounts (because of password expiry and need to update all AppPools when User passwords are changed - I need to maintain multiple servers).
所以,这是可能的。
推荐答案
您可以随时开始与不同的身份的过程中,可以重新启动服务器:
You can always start the process with a different identity that can restart the server:
var info = new ProcessStartInfo("shutdown.exe", "/r /t 0");
info.UserName = "accountWithAdminPermissions";
//A not-so-secure use of SecureString
var secureString = new SecureString();
var password = "abc123";
foreach (var letter in password)
{
secureString.AppendChar(letter);
}
info.Password = secureString;
var restart = new Process();
restart.StartInfo = info;
restart.Start();
如果你只是想给非管理帐户重新启动服务器的权限:
If you just want to give a non-Administrative account the permission to restart the server:
- 开启
secpol.msc
- 导航到本地Policies\User权利指派。
- 找到
关闭系统
。 - 添加帐户。
- Open
secpol.msc
. - Navigate to Local Policies\User Rights Assignment.
- Find
Shutdown The System
. - Add the account.
这可能是使用最小权限的帐户的一个好办法。这样,你就不必使用一个真正的大铁锤一样管理员组中的帐户。
This might be a good way of using an account for least privilege. That way you don't have to use a really big hammer like an account in the Administrator group.
Shutdown.exe的
(我相信)总是需要管理员权限。您可以参考这个MSDN职位一>上没有重新启动shutdown.exe的服务器。
Shutdown.exe
(I believe) always requires Administrator permissions. You can refer to this MSDN post on restarting the server without shutdown.exe.
这篇关于从ASP.NET应用程序重新启动服务器时,程序池是根据本地系统或LocalService帐户运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!