searching for a user in active directory by username

  • Thread starter Thread starter TheVillageCodingIdiot
  • Start date Start date
T

TheVillageCodingIdiot

Im creating a app that will pull a list of usernames in a txt doc and
then find them in active directory and set the "User must change
password at next login" attribut. I would like to limit it to a
specific out and all sub OU under it. Im having issues nailing down the
scope. I set the OU i want to start but it seems to go outside that OU
and also not filtering the objectclass to just users. This is what i
got so far. Also if i could get help checking that attribute to have
them change there password too. Thanks.
Imports System
Imports System.DirectoryServices

Namespace ActiveDirectorySearch
Public Class ADSearch
Shared Sub main(ByVal strUserName As String)
Const strLDAP = "LDAP://ou=MINN Corporate,ou=CORP
Users,dc=corp,dc=eschelon,dc=com"

Dim DSESearcher As DirectorySearcher = New DirectorySearcher(strLDAP)


DSESearcher.Filter = ("(objectClass=user)")

Dim objResults As SearchResult

For Each objResults In DSESearcher.FindAll()
Console.WriteLine(objResults.GetDirectoryEntry.Path.ToString)

Next
End Sub
End Class
End Namespace


any help would be great
 
Ok i got the issue with the searcher going out of scope, now I need to
get the "User must change password at next login" checked. Anyone know
how to do this. Sorry but im new to .Net and still finding my way
around it from vb6. Thanks
 
Back
Top