Hi
The following is part of a script that I use to retrieve details from a local LDAP database and present the results on screen:
The Binding has been done prior to this.
$dn = "cn=system";
$filter="(objectclass=*)";
$justthese = array('guid','cn');
$sr=ldap_list($ds, $dn, $filter, $justthese);
$info = ldap_get_entries($ds, $sr);
for ($n=0; $n<$info['count']; $n++) {
$system_cn = $info[$n]['cn'][0];
$system_guid[$system_cn] = $info[$n]['guid'][0];
}
foreach ($system_guid as $key => $value) {
echo "<br><b>System Name : " . "<font color='yellow'>". $key ."</font></b>";
echo "<br><table><tr>";
$dn = "guid=$value";
$filter="(objectclass=user)";
$justthese = array('cn','part_id','followmember');
$sr=ldap_search($ds, $dn, $filter, $justthese);
$info = ldap_get_entries($ds, $sr);
for ($n=0; $n<$info['count']; $n++) {
$part_id = $info[$n]['part_id'][0];
$usr = $info[$n]['cn'][0];
echo $part_id ." - ". $usr ."<br>";
}
echo "<hr align='left' width= '20%'>";
echo "</table></tr>";
}
The script works well resulting in:
System Name : Local Kettle Unit 1
103 - Margaret
134 - James
53 - Frank
System Name : Local Kettle Unit 3
43 - Mark
134 - James
53 - Frank
etc...
However a couple of the entries have duplicates in them:
System Name : Melt Bin 4a
43 - Mark
134 - James
53 - Frank
134 - James
98 - Sarah
87 - Paul
154 - Adam
As you can see '134 - James' appears twice.
How do I adjust the above script to only show unique entries
eg:
System Name : Melt Bin 4a
43 - Mark
134 - James
53 - Frank
98 - Sarah
87 - Paul
154 - Adam
I can't change the formatting of the LDAP database as this has been designed by an out sourced IT team.
They would produce this script for me at a cost - but as I've got it nearly working... can any one help !
Many Thanks