【发布时间】:2008-12-16 17:02:21
【问题描述】:
我正在尝试增强我的代码,以确定用户是否是给定 AD 组的成员。它本质上是有效的,除非该组的成员碰巧来自另一个(受信任的)域,因为它被存储为 foreignsecurityprincipal。
鉴于我对要测试的组和要检查的帐户都有一个有效的 DirectoryEntry 对象,我需要一个 DirectorySearcher 过滤器字符串,它可以让我确认该帐户在该组中,甚至如果该帐户是外国证券负责人。
(演示问题的VB.NET代码示例)
Dim ContainerGroup as DirectoryEntry = ... Code to get Group
Dim UserToCheckFor as DirectoryEntry = ... Code to get User
DSearcher = New DirectorySearcher(ContainerGroup, "(WHATCANIPUTINHERE)", New String() {"member;Range=0-5000"}, SearchScope.Base)
DSearcher.AttributeScopeQuery = "member"
'If an object is found, the account was in the group
Return (DSearcher.FindOne() IsNot Nothing)
【问题讨论】:
标签: .net active-directory ldap adsi