Hi,
I'm trying to create a web page for our internal intranet that will list users and there mobile numbers. I have the script below which shows all users, however I would like to filter based on a group (mobileusers), I've tried changing the filter, adding 'memberOf=mobileuser' however that returns 0 results.
How do I add this to the script?
Many thanks
Ben
<?php
$ldap_host = "ldap://server.domain.local";
$ldap_port = "389";
$base_dn = "OU=Users,DC=domain,DC=local";
$filter = "(&(objectClass=user)(objectCategory=person)(cn=*))";
$ldap_user = "CN=Administrator,DC=domain,DC=local";
$ldap_pass = "pwd";
$inforequired = array("displayname","mobile");
$connect = ldap_connect($ldap_host,$ldap_port)
or exit("Could not connect to LDAP server");
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
$bind = ldap_bind($connect, $ldap_user, $ldap_pass)
or exit("Could not bind to $ldap_host");
echo "Successful bind to $ldap_host with $bind<br><br>\n";
$read = ldap_search($connect, $base_dn, $filter, $inforequired)
or exit("Unable to search ldap server");
$info = ldap_get_entries($connect, $read);
echo $info["count"]." entries returned for $filter<br><br>\n";
if($info["count"] == 0)
{
print "<p>No information available";
}
else
{
print "<table><tr>"
. "<td>Name</td>"
. "<td>Mobile Number</td>"
. "</tr>";
for($i=0;$i<$info["count"];$i++)
{
$row[$i] = "<tr>"
. "<td>" . $info[$i]["displayname"][0] . "</td>"
. "<td>" . $info[$i]["mobile"][0] . "</td>"
. "</tr>";
}
sort($row);
for($i=0;$i<$info["count"];$i++) print $row[$i] . "\n";
print "</table>";
}
ldap_unbind($connect);
?>