从ASP.NET应用程序重新启动服务器时,程序池是根据本地系统或LocalService帐户运行 [英] Restart Server from ASP.NET application when AppPool is ran under LocalSystem or LocalService account

查看:253
本文介绍了从ASP.NET应用程序重新启动服务器时,程序池是根据本地系统或LocalService帐户运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能从由本地系统或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:


  1. 开启 secpol.msc

  2. 导航到本地Policies\User权利指派。

  3. 找到关闭系统

  4. 添加帐户。

  1. Open secpol.msc.
  2. Navigate to Local Policies\User Rights Assignment.
  3. Find Shutdown The System.
  4. 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屋!

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