T
TheVillageCodingIdiot
Im creating a app that will go through all the OU's and look for a
certain user by username. In doing some testing I noticed that its not
filtering everything out exept for user ObjectClass. It seems to be
pulling computers as well. Not sure why this is happening but need to
limit it to just user objects. Here is the code I have.
Imports System
Imports System.DirectoryServices
Namespace ActiveDirectorySearch
Public Class ADSearch
Shared Sub main(ByVal strUserName As String)
Dim DSESearcher As New DirectorySearcher()
DSESearcher.SearchScope = SearchScope.Subtree
DSESearcher.Filter = "(objectClass=user)"
Dim objResults As SearchResult
For Each objResults In DSESearcher.FindAll()
Console.WriteLine(objResults.GetDirectoryEntry.Properties("samaccountname").Value
& "...." & objResults.GetDirectoryEntry.Path)
Next
End Sub
End Class
End Namespace
certain user by username. In doing some testing I noticed that its not
filtering everything out exept for user ObjectClass. It seems to be
pulling computers as well. Not sure why this is happening but need to
limit it to just user objects. Here is the code I have.
Imports System
Imports System.DirectoryServices
Namespace ActiveDirectorySearch
Public Class ADSearch
Shared Sub main(ByVal strUserName As String)
Dim DSESearcher As New DirectorySearcher()
DSESearcher.SearchScope = SearchScope.Subtree
DSESearcher.Filter = "(objectClass=user)"
Dim objResults As SearchResult
For Each objResults In DSESearcher.FindAll()
Console.WriteLine(objResults.GetDirectoryEntry.Properties("samaccountname").Value
& "...." & objResults.GetDirectoryEntry.Path)
Next
End Sub
End Class
End Namespace