I am using a database table to list managers and people that report to them -- a parent/child relationship I use to populate a Treeview control. The problem is that this table is not kept updated so the data is incomplete.
My boss has asked me to use LDAP to query the Active directory to get this list. The problem is that I don't think that I can create a query as complex as needed to create the hierarchical type lists that I need. Also I don't believe that Active Directory has a fields that are "reports to" fields, or does it?
This is the query that populates the root level:
This is the query that populates the Sublevel (on demand):
Is there anyway that I could create queries against the Active Directory to get the same results?
My boss has asked me to use LDAP to query the Active directory to get this list. The problem is that I don't think that I can create a query as complex as needed to create the hierarchical type lists that I need. Also I don't believe that Active Directory has a fields that are "reports to" fields, or does it?
This is the query that populates the root level:
Code:
select userid, (firstname + ' ' + middlename + ' ' + lastname + ' - ' + jobtitle) as EmpName, " & _
"active, (select count(*) FROM employees " _
& "WHERE reportsto=hr.user_login) childnodecount FROM employees hr where reportsto = '" & ReportsTo & "' " & _
"AND (userid IS NOT NULL) AND (userid <> '') AND (hr.active = 1) order by firstname
Code:
select userid, (firstname + ' ' + middlename + ' ' + lastname + ' - ' + jobtitle) as EmpName, " & _
"active, (select count(*) FROM employees " _
& "WHERE reportsto=hr.userid) childnodecount FROM employees hr where reportsto = '" & ReportsTo & "' " & _
"AND (userid IS NOT NULL) AND (userid <> '') AND (hr.active = 1) order by firstname