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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
<?
function cmp($a,$b) {
global $fld1,$fld2,$fld3; // getting the fld defs from the main routine
global $info; // get search results from the main routine
$d=strcasecmp($info[$a][$fld1][0],
$info[$b][$fld1][0]);
if ($d==0) {
$d = strcasecmp($info[$a][$fld2][0],
$info[$b][$fld2][0]);
if ($d==0) {
$d= strcasecmp($info[$a][$fld3][0],
$info[$b][$fld3][0]);
}
}
if ($d==0) {
return 0;
} else {
return ($d>0)? 1 : -1;
}
}
//Données de connexion
$serveur_ldap = "nom de serveur";
$membre = "utilisateur";
$pass = "mot de passe";
$ldap_host = "serveur Ad";
$base_dn = " base";
$filter="(&(objectClass=user)(memberOf= groupe))";
$connexion = @ldap_connect($serveur_ldap);
ldap_set_option($connexion, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($connexion, LDAP_OPT_REFERRALS, 0);
$session = ldap_bind($connexion, $membre, $pass);
$sr=ldap_search($connexion, $base_dn, $filter);
$info = ldap_get_entries($connexion, $sr);
//modification pour le classement
$fld1="sn";
$fld2="givenname";
$fld3="description";
uksort($info,"cmp");
while (list($i, $value) = each($info)) {
$mynom = $info[$i]["cn"][0];
$nom = $info[$i]["displayname"][0];
$mynom=urlencode($mynom);
echo" <br><a href=\"information.php?cn=$mynom\">$nom</a>";
}
ldap_free_result($sr);
// on ferme la connexion au serveur LDAP
ldap_close($connexion);
?> |
Partager