title: LDAP Query for all owners of group
body: <h2>Problem</h2>
  <p>I need to write an LDAP query that given a <code>distinguishedName</code> for a <code>group</code> will return a list of all <code>users</code> who are owners/managers of the <code>group</code></p>
  <h3>Motivation</h3>
  <p>I am writing a VBA script that will allow an excel user to input a <code>DisplayName</code> for a <code>group</code> in a cell and press a button to receive (1) a list of members and (2) a separate list of group owners.</p>
  <h3>Progress</h3>
  <p>The first part works fine. I search the directory for <a href="https://stackoverflow.com/questions/7187994/memberof-vs-groupmembership-in-ldap-liferay">all users who have the group in their <code>memberof</code> field.</a></p>
  <p>For the owners, I successfully pulled the group's <code>managedBy</code> field, but it only contained information for a single user. This is the same user that appears in the &quot;Owner&quot; field when the group is viewed in Outlook's address book. There are many more users with ownership permissions for the list.</p>
  <h2>Examples</h2>
  <p>Here are the two  (slightly modified) queries I'm using now:</p>
  <h3>Query 1: Group Members (works)</h3>
  <pre><code>&lt;LDAP://dc=DOMAIN,dc=com&gt;;(&amp;(memberof=CN=GroupName));DisplayName;Subtree
  </code></pre>
  <h3>Query 2: Group Owners (single user returned)</h3>
  <pre><code>&lt;LDAP://dc=DOMAIN,dc=com&gt;;(&amp;(objectCategory=group)(DisplayName=&quot;Group Name&quot;));managedBy;Subtree
  </code></pre>
  <h2>The Question</h2>
  <p>How can I modify Query 2 to return all users with management permissions for the group?</p>
  <h2>Related Questions</h2>