Richard
Sat Jun 14 10:02:34 PDT 2008
Chad wrote:
>I am trying to reproduce functionality that is available on our company's
>intranet web site: To traverse the reporting heirarchy.
>
> On our web site, a "manager" manages a single group at every level of the
> tree. (i.e.. each person has opne and only 1 manager. each mgr manages
> exactly one dept.).
>
> Has anyone seen .NET code for displaying the *reporting* heirachy using a
> treeview display?
>
> Perhaps the 1:1 rule above is not standard and thisis the reason I can't
> find code to do this. Usually codeproject.com has everything
>
> Anyone see anything like this?
I assume you are talking about the Active Directory "Manager" and "Direct
Reports" fields on the "Organization" tab of ADUC. I've used VBScript to
document the reporting structure, so a Treeview control was not available. I
used indenting to show who reported to whom. I've used the Treeview control
in VB (to show OU and container hierachy of AD) and I'm sure it's as easy to
use in .NET. The trick is to first retrieve all top level managers (there
may be only one), users that have direct reports but no manager. The ADO
filter would be:
strFilter = "(&(objectCategory=person)(objectClass=user)" _
& "(!manager=*)(directReports=*))"
You would retrieve the Distinguished Names of the top level managers. Then
for each manager you need to recursively search for the direct reports with
a filter similar to:
strFilter = "(&(objectCategory=person)(objectClass=user)" _
& "(manager=" & strManager & "))"
where strManager is the Distinguished Name of the manager. For every direct
report retrieved, you need to search for any possible users reporting to
them. I have an example VBScript program that does this linked here:
http://www.rlmueller.net/OrganizationalStructure.htm
This isn't .NET, but the important part is the ADO queries and the recusive
method to walk the hierarchy. At each point where the script outputs, you
would add a node to the Treeview control. You just need to retain the parent
manager at each level so you add the node to the correct manager in the
hierachy.
--
Richard Mueller
MVP Directory Services
Hilltop Lab -
http://www.rlmueller.net
--