title: LDAP - List groups
body: <p>I need to list all groups within a certain group using PHP.  This is what I have so far:</p>
  
  <pre><code>&lt;?php
  $ldap_dn = "ou=People,dc=something,dc=something,dc=something,dc=au";
  $ldap_svr = "ldap.server.somewhere";
  $ldap_domain = "domain.somewhere";
  $conn=ldap_connect($ldap_svr) or die("Cannot connect to LDAP server!");
  
  ldap_set_option ($conn, LDAP_OPT_REFERRALS, 0);
  ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
  
  ldap_bind($conn,"user@domain.somewhere","password");
  
  
  $filter ="(ou=*)";
  $justthese = array("ou");
  
  $result=ldap_list($conn, $ldap_dn, $filter, $justthese) or die("No search data found."); 
  
  $info = ldap_get_entries($conn, $result);
  
  for ($i=0; $i &lt; $info["count"]; $i++) {
      echo $info[$i]["ou"][0] . '&lt;br /&gt;';
  }
  ?&gt;
  </code></pre>
  
  <p>This returns a list of groups, one of whch is 'Students', but I want to list all groups within 'Students'.  How can I do this?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Thanks to Fluffeh the Microsoft LDAP plugin allows me to search active directorys so I can tailor my PHP script accordingly, <code>e.g. $ldap_dn = "ou=Units,ou=Groups,dc=somewhere,dc=somewher,dc=somewhere,dc=au";</code></p>
  
  <p>So my mostly working code is:</p>
  
  <pre><code>&lt;?php
  $ldap_dn = "ou=Units,ou=Groups,dc=somewhere,dc=somewher,dc=somewhere,dc=au";
  $ldap_svr = "ldap.server.somewhere";
  $ldap_domain = "domain.somewhere";
  $conn=ldap_connect($ldap_svr) or die("Cannot connect to LDAP server!");
  
  ldap_set_option ($conn, LDAP_OPT_REFERRALS, 0);
  ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
  
  ldap_bind($conn,"user@domain.somewhere","password");
  
  
  $filter ="(cn=*)";
  $justthese = array('cn');
  
  $result=ldap_list($conn, $ldap_dn, $filter, $justthese) or die("No search data found."); 
  
  $info = ldap_get_entries($conn, $result);
  
  for ($i=0; $i &lt; $info["count"]; $i++) {
      echo $info[$i]["cn"][0] . '&lt;br /&gt;';
  }
  ?&gt;
  </code></pre>