Domain computer properties

a5m0d1

Member
Joined
Mar 14, 2010
Messages
15
Programming Experience
1-3
I have managed to get most of what I need done. I can search computers on my domain and then add the names of the computer and properties to a tree view.

I have it so it looks like this

Computers
---ICT01
------Service pack 3
------Last Logged on
------etc etc
---ICT02

Where can I get a list of all the properties I can get data from in regards to a domain computer.

I can pull the results when I know the name of the item but how can I just use no filters and then populate a listbox or treeview with every one so I can look at them?

Thanks for your time
G

VB.NET:
Imports System.DirectoryServices
Public Class Form1
    Dim dirEntry As DirectoryEntry
    Dim results As System.DirectoryServices.SearchResultCollection
    Dim nodecount As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TreeView1.Nodes.Add(New TreeNode("Computers"))
        Dim nodecount = 0
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Using searcher As New System.DirectoryServices.DirectorySearcher
            Dim sf As String
            Dim mydom As String
            mydom = TextBox2.Text
            sf = TextBox1.Text
            searcher.SearchRoot = New System.DirectoryServices.DirectoryEntry("LDAP://DC=" + mydom + ",DC=stname,DC=org,DC=uk")
            searcher.Filter = sf '(&(objectCategory=computer) (name=I*))
            'searcher.PropertyNamesOnly = true
            searcher.PropertiesToLoad.Add("name")
            searcher.PropertiesToLoad.Add("operatingSystemServicePack")
            'searcher.PropertiesToLoad.Add("")
            searcher.Sort = New System.DirectoryServices.SortOption("name", System.DirectoryServices.SortDirection.Ascending)
            searcher.SearchScope = DirectoryServices.SearchScope.Subtree
            searcher.SizeLimit = 0
            searcher.PageSize = 250

            results = searcher.FindAll
            If results IsNot Nothing Then

                For Each result As System.DirectoryServices.SearchResult In results

                    'get the actual directory
                    Dim dir As System.DirectoryServices.DirectoryEntry = result.GetDirectoryEntry

                    'within the organizational unit there are child entries
                    For Each childDirectory As System.DirectoryServices.DirectoryEntry In dir.Children
                        

                    Next

                    TreeView1.Nodes(0).Nodes.Add(New TreeNode(dir.Properties.Item("name").Value))
                    TreeView1.Nodes(0).Nodes(nodecount).Nodes.Add(New TreeNode(dir.Properties.Item("operatingSystemServicePack").Value))
                    
                    nodecount = nodecount + 1

                Next

            End If
        End Using


    End Sub

End Class
 
Last edited:
I found a script that I think gave me what I needed

VB.NET:
Set objSchema = GetObject("LDAP://schema/computer")
 
Wscript.Echo "Mandatory attributes"

For Each strAttribute in objSchema.MandatoryProperties
    Wscript.Echo strAttribute
Next
 
Wscript.Echo

Wscript.Echo "Optional attributes"

For Each strAttribute in objSchema.OptionalProperties
    Wscript.Echo strAttribute
Next
 
Back
Top