問題描述
問題:
我使用在以下位置找到的代碼http://support.microsoft.com/kb/306273
I use the code found at http://support.microsoft.com/kb/306273
添加一個windows用戶.問題是我需要將用戶添加到組中,但組名已本地化.
to add a windows user. The problem is i need to add the user to a group, but the groupnames are localized.
例如MS-example 使用英文計算機,這意味著您可以像這樣獲得來賓組:
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")
但在非英語計算機上,Guest"組名是本地化的,例如,在我的德語操作系統(tǒng)上,Guest 的組名是G?ste".
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")
然后就可以了.
現(xiàn)在如果操作系統(tǒng)是任何其他語言,我如何找到來賓用戶的名稱?或者如何從 sid 獲取來賓用戶名?
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 ?
注意:.NET 2.0,而不是 3.0 或 3.5
Note: .NET 2.0, not 3.0 or 3.5
推薦答案
正如您所指出的,組的名稱根據(jù)系統(tǒng)語言進行了本地化.
As you have pointed out, the names of groups are localised depending on system language.
對于像管理員"和訪客"這樣的知名"組,您應(yīng)該根據(jù) SID 進行檢索.來賓的 SID 是:
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
這里有一個眾所周知的 SID 列表:
There is a list of well known SIDs here:
http://support.microsoft.com/kb/243330
可以找到從 SID 獲取組名的代碼 這里
Code to get the group name from the SID can be found here
這篇關(guān)于如何獲取來賓/管理員的本地組名稱?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!