"Lubomir" <Lu*****@discus sions.microsoft .comwrote in message
news:92******** *************** ***********@mic rosoft.com...
Thanks fro answer.
My problem is, that I need to find some particular service. For exmaple I
need to work with "Network Service" and I need to pass its name to some
function.
If U run a non English version of OS, the name if this service will not be
"Network Service". So when I use the method you recommended, I gte a list
of
non-english names. How I will know, which one of them is "Network Service"
?
I think I should be able to find any particular service by his SID. This
SID
I guess is the same on all Windows OS. So using this SID I would get the
"Network Service" name is the particular localized language.
I don't know how to work with SIDs in C#. I didn't find any methods that
would use it for returning a service name.
Network Service is a windows account name, not a service name. Services are
"background processes" that have a non localized "Service Name" and a
localized "Display Name".
When looking for services, you use the "Service Name" because that does not
change across different localizations. However, the Display Name can be
(not necessarily is) different accross the different localizations.
That being said, if you want to get the "name" of the Network Service
account, you could do something like
using System.Security .Principal;
....
SecurityIdentif ier id = new
SecurityIdentif ier(WellKnownSi dType.NetworkSe rviceSid, null);
NTAccount acct = (NTAccount)id.T ranslate(typeof (NTAccount);
string networkServiceA ccountName = acct.Value;
I don't know if that final result is localized or not (I cannot remember
offhand). However, the first line creates the SID representation of the
account. I don't know what you'd want to do with this particular account
name, since you originally asked about finding services, not accounts.
--
Doug Semler, MCPD
a.a. #705, BAAWA. EAC Guardian of the Horn of the IPU (pbuhh).
The answer is 42; DNRC o-
Gur Hfrarg unf orpbzr fb shyy bs penc gurfr qnlf, abbar rira
erpbtavmrf fvzcyr guvatf yvxr ebg13 nalzber. Fnq, vfa'g vg?