我需要在我的程序中获取组中的用户登录名列表。
这是我到目前为止所拥有的,但它只返回所有用户......我需要将其缩减为一组中的用户,其中我有这个名称。
Option Explicit On
Imports System.DirectoryServices
Imports System.DirectoryServices.ActiveDirectory
Module Module1
Sub Main()
Dim ADEntry As New DirectoryServices.DirectoryEntry("LDAP://OU=Users,OU=Irvine,OU=KNS,DC=corp,DC=kns,DC=com")
Dim objSearch As New System.DirectoryServices.DirectorySearcher(ADEntry)
Dim oResults As DirectoryServices.SearchResultCollection
Dim oResult As DirectoryServices.SearchResult
' THIS DOESNT WORK
' objSearch.Filter = "department = engineering"
oResults = objSearch.FindAll
For Each oResult In oResults
Console.WriteLine(oResult.GetDirectoryEntry.Properties("sAMAccountName").Value)
Next
End Sub
End Module