1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <?php
//Settings
error_reporting (E_ALL ^ E_NOTICE);
ini_set("memory_limit","500M");
ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
//ldap_set_option($ad, LDAP_OPT_SIZELIMIT, 500);
ldap_set_option($ad, LDAP_OPT_REFERRALS, 0);
$ad = ldap_connect("ldap://host") or die("Couldn't connect to AD!");
$bd = ldap_bind($ad,"user@host.com","password") or die("Couldn't bind to AD!");
//Auth
$dn = "OU=MAD,DC=host,DC=com";
$filter = "(&(objectCategory=person)(objectClass=user)(physicaldeliveryofficename=A*)(employeeid=1*))";
//Auth
$result = ldap_search($ad, $dn, $filter);
$entries = ldap_get_entries($ad, $result);
$total= ldap_count_entries($ad,$result);
echo $total;
//Bucle
for ($i=0; $i<$entries["count"]; $i++)
{
echo $entries[$i]["employeeid"][0]." ".$entries[$i]["physicaldeliveryofficename"][0]." ".$entries[$i]["name"][0]." ".$entries[$i]["accountexpires"][0]."\n";
}
ldap_unbind($ad);
?> |
Partager