让用户列表从广告组 [英] Getting users list from an AD Group

查看:167
本文介绍了让用户列表从广告组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个域名,我不知道该域名的服务器名称或ip地址的,我所知道的只是域名。在该网站下创建的组。加入到域中的用户属于不同的领域。我必须得到用户的列表,不论其域名,添加到该组,并显示在列表框中。我不得不这样做在C#中的Web应用程序。

I have a domain and I am not aware of the domain server name or IPaddress, all I know is just the domain name. A group created under this domain. The users added to this domain belong to different domains. I have to get the list of users, irrespective of their domain, added to that group and show it in a list box. I have to do this in C# web application.

请指点一下。

推荐答案

使用.NET 3.5和 System.DirectoryServices.AccountManagement 命名空间,你应该可以写的东西这样的:

Using .NET 3.5 and the System.DirectoryServices.AccountManagement namespace, you should be able to write something like:

// create domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);

// fetch your group
GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, "groupname");

// enumerate over the group's members
foreach (Principal p in group.Members)
{
   Console.WriteLine("Principal '{0}', type '{1}'", p.Name, p.StructuralObjectClass);
}

这应该列出所有成员的该组的(用户和组)。

This should list all the member's of that group (users and groups).

这篇关于让用户列表从广告组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆