Which user permission does a service need to start/stop other services?

≯℡__Kan透↙ 提交于 2020-01-01 05:56:08

问题


I've wrote a service that should start/stop other services. This is the code I'm using:

ServiceController sc = new ServiceController("servicename");
if(sc.Status != ServiceControllerStatus.Running)
{
    sc.Start();
}

This is the callstack of the exception. (Sorry, but the message is localized in german, but that's not relevant for understanding my problem)

System.InvalidOperationException: Der Dienst SCardSvr kann nicht auf dem

Computer . geöffnet werden. ---> System.ComponentModel.Win32Exception: Zugriff verweigert
--- Ende der internen Ausnahmestapelüberwachung ---
bei System.ServiceProcess.ServiceController.GetServiceHandle(Int32 desiredAccess)
bei System.ServiceProcess.ServiceController.Start(String[] args)
bei System.ServiceProcess.ServiceController.Start()

Currently I'm running the service under 'Networkservice'. I guess that account does not suffice the necessary user rights.
I'm going to create a new user that the most minimal permission required to start/stop arbitrary serivces.
What permissions does this new useraccount need?


回答1:


Does it need to be able to start and stop arbitrary services, or a specific set?

For more fine grained control you can set permissions against a specific service. See http://msmvps.com/blogs/erikr/archive/2007/09/26/set-permissions-on-a-specific-service-windows.aspx?CommentPosted=true#commentmessage

Members of the 'power users' group have some ability to start and stop services. See http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/windows_security_default_settings.mspx?mfr=true



来源:https://stackoverflow.com/questions/3839501/which-user-permission-does-a-service-need-to-start-stop-other-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!