为什么拟人身份比原始身份拥有更少的权利?

本文关键字:身份 拥有 原始 为什么 | 更新日期: 2023-09-27 17:50:42

我有一个ASP。. NET MVC2服务,它是由cassini/http托管的。基于系统的web服务器。业务进程以本地管理员身份运行。

不,我想读取一个服务的状态使用:

using (var sc = new ServiceController(_ServiceName))
{
    return sc.Status == ServiceControllerStatus.Running;
}

这个工作很好,然后模拟关闭。但我想使用windows身份验证和模拟。所以当我加上

<identity impersonate="true" />

到web.config。调用sc.Status失败并产生InvalidOperationException。内部异常是Win32Exception/ACCESS_DENIED

"System.InvalidOperationException" caught. 
Message=Cannot open service 'abcd' on computer '.' .
Source=System.ServiceProcess
StackTrace:
   at System.ServiceProcess.ServiceController.GetServiceHandle(Int32 desiredAccess)
   at System.ServiceProcess.ServiceController.Start(String[] args)
   at System.ServiceProcess.ServiceController.Start()
InnerException: System.ComponentModel.Win32Exception
   Message=Access denied
   ErrorCode=-2147467259
   NativeErrorCode=5
   InnerException: 

模拟的标识与进程标识相同。那么,为什么模拟标识的访问权限比流程标识少呢?如何才能避免这种情况?

系统:Windows 7, UAC启用

为什么拟人身份比原始身份拥有更少的权利?

您的服务器可能不受委托信任。

请注意,我解决了上述问题-请参阅我的帖子在这里:ServiceController.start()和ServiceController.stop()抛出异常?原文在这里:https://thommck.wordpress.com/2011/12/02/how-to-allow-non-admins-to-start-and-stop-system-services/