Ive tried and tried to fix this issue.
I cant get the objectGuid from a computer via Active Directory.
I cant work out the converstion to a string
I have added some code below to show where I am going wrong
It works fine write up until it tries to update the tree view with the "objectGuid"
Error = Conversion from type 'Byte()' to tyoe 'integer' is not valid
I cant get the objectGuid from a computer via Active Directory.
I cant work out the converstion to a string
I have added some code below to show where I am going wrong
It works fine write up until it tries to update the tree view with the "objectGuid"
Error = Conversion from type 'Byte()' to tyoe 'integer' is not valid
VB.NET:
'------------------------Computers-----------------------
Using searcher As New System.DirectoryServices.DirectorySearcher
searcher.SearchRoot = New System.DirectoryServices.DirectoryEntry("LDAP://DC=wigan,DC=org,DC=uk")
searcher.Filter = "(&(objectCategory=computer) (name=*))"
searcher.PropertiesToLoad.Add("name")
searcher.PropertiesToLoad.Add("operatingSystemServicePack")
searcher.PropertiesToLoad.Add("operatingSystem")
searcher.PropertiesToLoad.Add("logonCount")
searcher.PropertiesToLoad.Add("distinguishedName")
searcher.PropertiesToLoad.Add("description")
searcher.PropertiesToLoad.Add("objectGUID")
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).ImageIndex = 1
TreeView1.Nodes(0).Nodes(nodecount).SelectedImageIndex = 1
TreeView1.Nodes(0).Nodes(nodecount).Nodes.Add(New TreeNode(dir.Properties.Item("operatingSystemServicePack").Value))
TreeView1.Nodes(0).Nodes(nodecount).Nodes.Add(New TreeNode(dir.Properties.Item("operatingSystem").Value))
TreeView1.Nodes(0).Nodes(nodecount).Nodes.Add(New TreeNode(dir.Properties.Item("distinguishedName").Value))
TreeView1.Nodes(0).Nodes(nodecount).Nodes.Add(New TreeNode(dir.Properties.Item("logonCount").Value))
TreeView1.Nodes(0).Nodes(nodecount).Nodes.Add(New TreeNode(dir.Properties.Item("description").Value))
TreeView1.Nodes(0).Nodes(nodecount).Nodes.Add(New TreeNode(dir.Properties.Item("objectGUID").Value))
TreeView1.Nodes(0).Nodes(nodecount).Nodes(0).ImageIndex = 2
TreeView1.Nodes(0).Nodes(nodecount).Nodes(0).SelectedImageIndex = 2
TreeView1.Nodes(0).Nodes(nodecount).Nodes(1).ImageIndex = 2
TreeView1.Nodes(0).Nodes(nodecount).Nodes(1).SelectedImageIndex = 2
TreeView1.Nodes(0).Nodes(nodecount).Nodes(2).ImageIndex = 2
TreeView1.Nodes(0).Nodes(nodecount).Nodes(2).SelectedImageIndex = 2
TreeView1.Nodes(0).Nodes(nodecount).Nodes(3).ImageIndex = 2
TreeView1.Nodes(0).Nodes(nodecount).Nodes(3).SelectedImageIndex = 2
TreeView1.Nodes(0).Nodes(nodecount).Nodes(4).ImageIndex = 2
TreeView1.Nodes(0).Nodes(nodecount).Nodes(4).SelectedImageIndex = 2
TreeView1.Nodes(0).Nodes(nodecount).Nodes(4).SelectedImageIndex = 2
TreeView1.Nodes(0).Nodes(nodecount).Nodes(5).SelectedImageIndex = 2
TreeView1.Nodes(0).Nodes(nodecount).Nodes(5).SelectedImageIndex = 2
TreeView1.Nodes(0).Expand()
nodecount = nodecount + 1
Next
End If
End Using
Last edited: