[Solved] LDAP - Getting a list of members in a group?

Edit:

It was the loop at the bottom that was wrong. print_r() showed everything :slight_smile:

This is what I have so far (I snipped it somewhere and just changed the info)


$ldapServer = 'localhost';
$ldapBase = 'cn=group1,ou=groups,ou=internal,O=CORP';

/*
 * try to connect to the server
 */
$ldapConn = ldap_connect($ldapServer);
if (!$ldapConn)
{
  die('Cannot Connect to LDAP server');
}

/*
 * bind
 */
$ldapBind = ldap_bind($ldapConn,"cn=root",'password');
if (!$ldapBind)
{
  die('Cannot Bind to LDAP server');
}

/*
 * set the ldap options
 */
ldap_set_option($ldapConn, LDAP_OPT_PROTOCOL_VERSION, 3);

/*
 * search the LDAP server
 */
$ldapSearch = ldap_search($ldapConn, $ldapBase, "(member=*)",array('member'));
$ldapResults = ldap_get_entries($ldapConn, $ldapSearch);

for ($item = 0; $item < $ldapResults['count']; $item++)
{
  for ($attribute = 0; $attribute < $ldapResults[$item]['count']; $attribute++)
  {
   $data = $ldapResults[$item][$attribute];
   echo $data.":&nbsp;&nbsp;".$ldapResults[$item][$data][0]."<br>";
  }
  echo '<hr />';
}


It only returns the first member of the group, not all of them.
each person in the group looks like this in the Admin Client

member uid=user1,ou=people,ou=internal,o=corp
member uid=user2,ou=people,ou=internal,o=corp
member uid=user3,ou=people,ou=internal,o=corp
member uid=user4,ou=people,ou=internal,o=corp

I’m guessing it doesn’t know to put the rest in an array since the name (member) is all the same?