如何获取来宾/管理员的本地组名称?

时间:2022-11-26
本文介绍了如何获取来宾/管理员的本地组名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

问题:

我使用在以下位置找到的代码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"组名是本地化的,例如,在我的德语操作系统上,Guest 的组名是Gste".

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 "Gste".

这意味着要在我的计算机上运行支持示例,我需要将该行更改为

Which means for the support example to run on my computer i need to change that line to

grp = AD.Children.Find("Gste", "group")

然后就可以了.

现在如果操作系统是任何其他语言,我如何找到来宾用户的名称?或者如何从 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

推荐答案

正如您所指出的,组的名称根据系统语言进行了本地化.

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

对于像管理员"和访客"这样的知名"组,您应该根据 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

这篇关于如何获取来宾/管理员的本地组名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:使用 DirectoryServices.AccountManagement 从 OU 获取组 下一篇:通过电子邮件地址在 ActiveDirectory 中查找用户

相关文章

最新文章