Permissions required for a local user to query services

permissionsservicewindows-server-2012

I'm trying to write an application, that is running as a local user on the server, and needs access to enumerate services, and potentially even control them (start/stop).

Is being a part of the administrators group the only way this user would be able to get access to this functionality (being used via the ServiceController class)? If easier, I'd be ok with even just being able to enumerate the list of services (the interactive starting/stopping isn't a show-stopper). Would adding the user to the power user's group work?

Thanks!

edit: http://msdn.microsoft.com/en-us/library/windows/desktop/ms685981(v=vs.85).aspx#access_rights_for_the_service_control_manager

Best Answer

The Power Users group is never the answer. It's an old legacy thing. Best to just consider it non-existent.

If you want to set permissions on individual Windows services in a granular way, you can, but it's nowhere near as easy/intuitive as setting permissions on a file

To view the current permissions of a Windows service:

C:\Users\Ryan>sc sdshow netlogon

D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCR
RC;;;IU)(A;;CCLCSWLOCRRC;;;SU)

To set the permissions on a single Windows service, for example, so that a non-admin user can start and stop a particular service:

sc sdset netlogon "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;RPWPCR;;;S-1-5-21-2103278432-2794320136-1883075150-1000)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)"
[SC] SetServiceObjectSecurity SUCCESS

That looks awful, doesn't it? That goo is called SDDL - Security Descriptor Definition Language.

This article is a pretty good primer on how to interpret SDDL and do what you're trying to do.

You can also use Security Templates and Group Policies to accomplish the same thing:

Security Template