troubleshooting Question

Getting direct reports under another manager's direct reports list

Avatar of Lazaro Rondon
Lazaro Rondon asked on
ExchangeOutlookC#Active DirectoryPowershell
4 Comments1 Solution295 ViewsLast Modified:
I've been trying to figure out how to do this but I'm always met with a bump on the road. What I'm trying to do is to get the reporting people under my manager's direct reports list; so for example, "Alex" is a direct report under my manager, however, when you go into his organization you see that he also has direct reports that report directly to him - I am trying to get "those" reports not only from his side but from anyone else in the list that has direct reports as well. What is needed for me to effectively execute that idea? Many thanks!

This is my code to only get Direct Reports under my manager tree:
    public void GetManagerDirectReports()
            Application App = new Application();
            AddressEntry currentUser = App.Session.CurrentUser.AddressEntry;
            if (currentUser.Type == "EX")
                ExchangeUser manager = currentUser.GetExchangeUser().GetExchangeUserManager();
                if (manager != null)
                    AddressEntries addrEntries = manager.GetDirectReports();
                    if (addrEntries != null)
                        foreach (AddressEntry addrEntry in addrEntries)
                            ExchangeUser exchUser = addrEntry.GetExchangeUser();
                            StringBuilder sb = new StringBuilder();
                            sb.AppendLine("Name: "
                                + exchUser.Name);
                            sb.AppendLine("Title: "
                                + exchUser.JobTitle);
                            sb.AppendLine("Department: "
                                + exchUser.Department);
                            sb.AppendLine("Email: "
                                + exchUser.PrimarySmtpAddress);

Open in new window

Freelance programmer / Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros