I have the need in my program to get the list of user logon names in a group.
This is what I have so far but it only returns all the users...which I need cut down to those in a group, of which i have the name of.
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