Tom Powers
asked on
Active directory Ou with computer names in a treeview in vb.net
I am trying to create a program that loads computernames in the treeview control limited to one OU IN vb.net
I can load a combobox like this
I can load a combobox like this
Public Sub ADComputers()
Dim dirEntry As DirectoryEntry = New DirectoryEntry()
' NOTE: This path should be comma delimited, not semi-colon delimited
' Each label in the domain name should be a separate Domain Component (DC)
dirEntry.Path = "LDAP://OU=XXX,OU=Computer Accounts,DC=XXX,DC=XXX,DC=XXX,DC=org"
Dim mySearcher As DirectorySearcher = New DirectorySearcher(dirEntry)
' This value can be passed in the constructor if preferred.
mySearcher.Filter = "(objectClass=Computer)"
mySearcher.PageSize = 1001
For Each resEnt As SearchResult In mySearcher.FindAll()
TSCmbADC.Items.Add(resEnt.Properties("name")(0).ToString())
' List box is a bit simple for these unless I missed something
' lbADUsers.Items.Add(resEnt.Properties("sAMAccountName")(0).ToString())
' lbADUsers.Items.Add(resEnt.Properties("aDSPath")(0).ToString())
' And this one needs some work unless you're attaching to every object within the directory.
' lbADUsers.Items.Add(resEnt.Properties("objectGUID")(0).ToString())
Next
txtComputerCount.Text = TSCmbADC.Items.Count
End Sub
i JUST DON'T UNDERSTAND THE TREEVIEW. Thnaks Guys
ASKER
KLAVS thanks I know the amount of computers in My Ou for my Hospital is 1430 and grows every week or Month.
So how would I use just ouNode.Nodes.Add(New TreeNode("name")) in one line to loop until it is complete. then use
your statement 5:yourTreeViewControl.Node s.Add(ouNo de) line ? I appreciate your help bigtime. Thanks
So how would I use just ouNode.Nodes.Add(New TreeNode("name")) in one line to loop until it is complete. then use
your statement 5:yourTreeViewControl.Node
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Klavs R you nailed it down perfectly Thank You
To add items use this code:
Open in new window
Hope this helps you.