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
| <?php
$ldapconn = ldap_connect("192.168.4.51")
or die("Could not connect to LDAP server.");
ldap_set_option($ldapconn,LDAP_OPT_PROTOCOL_VERSION, 3);
if ($ldapconn) {
$ldapbind = ldap_bind($ldapconn,"cn=admin,dc=****,dc=fr","***");
if ($ldapbind) {
$ldap_basedn="dc=univ-bpclermont,dc=fr";
$result=ldap_search($ldapconn,"ou=people,".$ldap_basedn,"(objectclass=*)");
$info = ldap_get_entries($ldapconn, $result);
for ($i=0; $i<$info["count"]; $i++)
{
$id = explode("=",$info[$i]["dn"],-1);
$id2 = explode(",",$id[1],-1);
echo $id2[0];
$info[$i][userpassword][0];
}
echo "Number of entries found: " . ldap_count_entries($ldapconn, $result);
ldap_close($ldapconn);
} else {
echo "LDAP bind anonymous failed...";
}
}
?> |
Partager