我有以下代码从Active Directory(AD)中提取特定安全组的用户,有趣的是它适用于一个域,但不适用于另一个域。 执行搜索后,它始终不会为变量“allResults”返回任何内容。 很奇怪,我真的需要建议。 我在那里确认了AD组及其现在的用户,登录AD的用户凭据是正确的 对于有效的两个域,它们就像xxx.com,但是没有像xxx.local那样工作的那个可能是问题吗?
Dim myLdapConnection As New DirectoryEntry(ADServer, ADUser, ADPwd)
Dim search As New DirectorySearcher(myLdapConnection, "(objectCategory=group)")
With search
.Filter = "sAMAccountName=" & ApproveGroup
.PropertiesToLoad.Add("member")
End With
'a = "sAMAccountName=" & ApproveGroup
'("(objectClass=user)")
Dim strUsers As String
Dim intEqualsIndex As Integer
Dim intCommaIndex As Integer
search.CacheResults = True
Dim allResults As SearchResult = search.FindOne
If IsNothing(allResults) Then
lblresponse.Text = "No member exists in this group (" & ApproveGroup & ")"
lblresponse.Visible = True
Exit Sub
End If