Re: Browsing host services
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Thu, 11 Aug 2005 11:42:45 +0200
<bk> wrote in message news:ePvwMrgnFHA.2444@xxxxxxxxxxxxxxxxxxxxxxx
>
> "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx> wrote in message
> news:%23jxAgybnFHA.2904@xxxxxxxxxxxxxxxxxxxxxxx
>>
>> "r" <razgrp@xxxxxxxxx> wrote in message
>> news:1123683024.045872.81400@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>> Hi,
>>> I would like to create a dialog that shows all services in the
>>> computer, much like services option in the control panel.
>>> How can I traverse all services on the computer?
>>> Thanks in advance
>>>
>>
>> Use the System.Management namespace classes and WMI for these kind of
>> management tasks....
>
> My problem with WMI is that not all functionality seems to match the
> WinAPI for the same task,
>
> Take for example changing the user that a service runs under (error
> checking removed):
>
> public static void ChangeUser(string name, string userName, string
> password) {
> ManagementObject service = new ManagementObject("Win32_Service=" + "\""
> + name + "\"");
> ManagementBaseObject parameters =
> service.GetMethodParameters("Change");
> parameters["StartName"] = userName;
> parameters["StartPassword"] = password;
> service.InvokeMethod("Change", parameters, null);
> }
>
> This works as you would expect but what it doesn't do which the WinAPI
> function does do is give the user the "Logon as a Service" right, which
> means you have to resort to other api's
Well that's exactly the kind of "convenience" which I don't like when using
the SC API's and the ServiceProcessInstaller class, why?
1. An account will automatically receive the "SeInteractiveLogonRight"
privilege when the service is installed, but it won't (and it can't) be
removed when the service is uninstalled. In a test environment you might end
with a bunch of accounts that are granted this privilege without any good
reason....
2. User privilege management and application management are separate tasks,
that means that you should configure your service accounts before you
install your application(s) aka. service(s). Service accounts should have
restricted privileges anyway, so picking an arbitrary user account to run as
a service is not good security practice anyway.
Note also that "User privilege management" is possible using
System.Management through the RSOP WMI namespace (XP and higher).
Willy.
.
- Follow-Ups:
- Re: Browsing host services
- From: bk
- Re: Browsing host services
- References:
- Browsing host services
- From: r
- Re: Browsing host services
- From: Willy Denoyette [MVP]
- Re: Browsing host services
- From: bk
- Browsing host services
- Prev by Date: Re: Abstract class using an interface
- Next by Date: Re: Abstract class using an interface
- Previous by thread: Re: Browsing host services
- Next by thread: Re: Browsing host services
- Index(es):
Relevant Pages
|