How can I get the local group name for guests/administrators?

Stefan Steiger picture Stefan Steiger · Jul 9, 2010 · Viewed 10.3k times · Source

Question:

I use the code found at http://support.microsoft.com/kb/306273

to add a windows user. The problem is i need to add the user to a group, but the groupnames are localized.

E.g. the MS-example uses an english computer, which means you can get the guest group like this: grp = AD.Children.Find("Guests", "group")

But on a non-english computer, the 'Guest' groupname is localized, meaning for example on my german language OS, the group name for Guests is "Gäste".

Which means for the support example to run on my computer i need to change that line to grp = AD.Children.Find("Gäste", "group")

then it works.

Now if the OS is any other language, how can I find the name for the guest user ? Or how can i get the guest user name from a sid ?

Note: .NET 2.0, not 3.0 or 3.5

Answer

Cocowalla picture Cocowalla · Jul 9, 2010

As you have pointed out, the names of groups are localised depending on system language.

For 'well known' groups like 'Administrators' and 'Guests' you should retrieve based on the SID. The SID for Guests is:

S-1-5-32-546

There is a list of well known SIDs here:

http://support.microsoft.com/kb/243330

Code to get the group name from the SID can be found here