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 30
|
<?php
$host = "***.***.***.***";
$port = "389";
$dn= "OU=test,DC=mitjavila,DC=loc";
$adConn = ldap_connect($host, $port) or die("La connection a échouée!");
//protocole version et bind
@ldap_set_option($adConn, LDAP_OPT_PROTOCOL_VERSION, 3) or die ("Protocole Ldap V1 inapplicable");
@ldap_set_option($adConn, LDAP_OPT_REFERRALS, 0) or die ("Protocole Ldap V2 inapplicable");
$bd = @ldap_bind($adConn,$_SESSION['login'],$_SESSION['password']);
if (isset($_SESSION['login']) && isset($_SESSION['password'])) {
$user= $_SESSION['login'];
$filter="(|(userPrincipalName=$user) (givenName=$user))";
$justthese= array ("sn");
$sr = ldap_search ($adConn, $dn, $filter, $justthese);
$info = ldap_get_entries ($adConn, $sr);
print ($info);
//echo $info ["count"]."entrie returned";
//for ($i=0;$i < $info["count"];$i++)
//{
//echo 'dn est : '.$info[$i]["dn"].'<br />';
//}
//}
//else {
//echo 'Les variables ne sont pas déclarées.';
}
?> |
Partager