title: How to find manager of department
body: <p>I'm working with Active Directory currently.  I am able to pull a list of everyone who works in a department, but I am not sure how to tell which one is the manager.</p>
  
  <pre><code>public void MemberOf(string department)
          {
              DirectoryEntry de = new DirectoryEntry("LDAP://server.server.com");
  
              DirectorySearcher ds = new DirectorySearcher(de);
  
              ds.Filter = ("(&amp;(objectCategory=person)(objectClass=User)(department=" + department + "))");
              ds.SearchScope = SearchScope.Subtree;
  
              foreach (SearchResult temp in ds.FindAll())
              {
                  string test1 = temp.Path;
              }
          }
  </code></pre>
  
  <p>This will return a list of people one of them being the manager the rest being direct reports to the manager.</p>