查明 AD 中的组是否属于通讯组?
我正在使用 ASP.net 和 C#,并且对 Active Directory 知之甚少。我收到了按以下步骤编写程序的任务:
为 ASP.net 应用程序提供了用户的用户名。
应用程序应查询具有给定用户名的用户的所有组。
然后,应用程序应将这些组显示在两个单独的列表中,一个列表包含通讯组,另一个列表包含其余组。
现在,查询所有组就很容易了。但是如何检查该组是否在通讯组中呢?
我没有得到更多信息。
有什么属性或者我可以检查的东西吗?
I'm using ASP.net with C# and have a very little idea about Active Directory. I've been given a task to write a program in steps below:
The ASP.net application is given the username of a user.
The application should query all the groups of the user with the given username.
Then the application should display these groups in two separate lists one consisting of the distribution groups and in other list, the rest of the groups.
Now, the querying for all the groups is easy. But how can I check whether the group is in distribution group or not?
I have not been given more information.
Any attribute or something I can check?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此代码将检索所有启用电子邮件的组,无论它是安全组还是通讯组。 (看到您对 marc_s 答案的评论后,我猜这实际上就是您的经理正在寻找的)。
This code will retrieve all your email enabled groups, regardless of whether it is a security or distribution group. (Having seen your comment to marc_s's answer, I'm guessing this is actually what your managers are looking for).
您可以从名为 Groupe-Type(最后一行)。
您可以在此答案中找到或在 这另一个不同检索用户所属组的方法。
您可以在此处找到如何检索用户。
You can retreive this information from an attribute called Groupe-Type(last line).
You can find in this answer or at the botton of this other one different ways to retreive groups a user belongs to.
You can find here how to retreive user.
由于您使用的是 .NET 3.5 及更高版本,因此您应该检查
System.DirectoryServices.AccountManagement
(S.DS.AM) 命名空间。在这里阅读所有相关内容:基本上,您可以定义域上下文并轻松查找 AD 中的用户和/或组:
新的 S.DS.AM 使在 AD 中使用用户和组变得非常容易!
Since you're on .NET 3.5 and up, you should check out the
System.DirectoryServices.AccountManagement
(S.DS.AM) namespace. Read all about it here:Basically, you can define a domain context and easily find users and/or groups in AD:
The new S.DS.AM makes it really easy to play around with users and groups in AD!