G
Guest
to all,
I was wondering if anyone has sample code that I can use to get information
about a computer in active directory. For example, I want to know the date
to when a computer was joined to a domain. Here is what I'm using so far but
don't get the information that I want. Any help would be greatly
appreciated. I have looked at all the various methods for resEnt but non led
me to information about my test computer.
Dim ENTRY As System.DirectoryServices.DirectoryEntry = New
System.DirectoryServices.DirectoryEntry("LDAP://OU=Offices, DC=Test,DC=COM")
Dim MYSEARCHER As System.DirectoryServices.DirectorySearcher = New
System.DirectoryServices.DirectorySearcher(ENTRY)
MYSEARCHER.Filter = ("(&(objectclass=computer)(name=testcomputer1))")
Dim resEnt As System.DirectoryServices.SearchResult
For Each resEnt In MYSEARCHER.FindAll()
Try
Console.WriteLine("rocessing:" &
Mid(resEnt.GetDirectoryEntry().Name.ToString(), 4))
Catch ex As Exception
Console.WriteLine("Trying to Connect to: " &
resEnt.GetDirectoryEntry().Name.ToString() & vbCrLf & ex.Message.ToString())
End Try
Next
I was wondering if anyone has sample code that I can use to get information
about a computer in active directory. For example, I want to know the date
to when a computer was joined to a domain. Here is what I'm using so far but
don't get the information that I want. Any help would be greatly
appreciated. I have looked at all the various methods for resEnt but non led
me to information about my test computer.
Dim ENTRY As System.DirectoryServices.DirectoryEntry = New
System.DirectoryServices.DirectoryEntry("LDAP://OU=Offices, DC=Test,DC=COM")
Dim MYSEARCHER As System.DirectoryServices.DirectorySearcher = New
System.DirectoryServices.DirectorySearcher(ENTRY)
MYSEARCHER.Filter = ("(&(objectclass=computer)(name=testcomputer1))")
Dim resEnt As System.DirectoryServices.SearchResult
For Each resEnt In MYSEARCHER.FindAll()
Try
Console.WriteLine("rocessing:" &
Mid(resEnt.GetDirectoryEntry().Name.ToString(), 4))
Catch ex As Exception
Console.WriteLine("Trying to Connect to: " &
resEnt.GetDirectoryEntry().Name.ToString() & vbCrLf & ex.Message.ToString())
End Try
Next