I’m working on a VB.Net project in which I have to use TreeView control filled with the Active Directory structure. The AD is very big, with hundreds of OUs and subOUs. Because of the size of AD I can’t fill the TreeView with the whole AD structure “in one shot” because it would take too long.
What I want to do first is to show just the first level of OUs/Containers (just under the domain). That I did using the code:
I find first level of OUs/Containers. These are returned using LDAP search (OneLevel) in SearchResultCollection variable. I now build the tree of the results under the domain in the following loop:
That creates the view of the first level OUs.
Here’s what I want to do now, and don’t know how to do it:
I want to put the “+” in front of the OUs that have subOUs without adding nodes. I know which OUs have subOUs, just need to get this “+”.
Then, clicking on the “+”, I want to get next level of OUs and add child nodes “on the fly”. The LDAP search I can do, just need the TreeViewCtl part.
Now I need some suggestions from those of you who understand my goal and know how to accomplish it.
Thanks in advance!
What I want to do first is to show just the first level of OUs/Containers (just under the domain). That I did using the code:
Code:
Dim rootNode as TreeNode = Nothing
‘Creating the top node with domain name
TreeViewCtl.Nodes().Clear()
rootNode = TreeViewCtl.Nodes.Add(“Domain.Net”)
I find first level of OUs/Containers. These are returned using LDAP search (OneLevel) in SearchResultCollection variable. I now build the tree of the results under the domain in the following loop:
Code:
Dim searchResults As SearchResultCollection
...
For Each foundOU In searchResults
...
newChild = New TreeNode(sOU)
rootNode.Nodes.Add(newChild)
...
Next
That creates the view of the first level OUs.
Here’s what I want to do now, and don’t know how to do it:
I want to put the “+” in front of the OUs that have subOUs without adding nodes. I know which OUs have subOUs, just need to get this “+”.
Then, clicking on the “+”, I want to get next level of OUs and add child nodes “on the fly”. The LDAP search I can do, just need the TreeViewCtl part.
Now I need some suggestions from those of you who understand my goal and know how to accomplish it.
Thanks in advance!