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
|
function get_microtime()
{
list($tps_usec, $tps_sec) = explode(" ",microtime());
return ((float)$tps_usec +(float)$tps_sec);
}
$CheminAd = 'OU=LesGens,DC=local,DC=fr';
$NomChercher = 'user*';
$cmd = 'dsquery user -name '.$NomChercher.' '.$CheminAd;
$NewChemin = 'OU=TEST,OU=LesGens,DC=local,DC=fr';
$cpt = 0;
echo "Chemin Recherche : ".$CheminAd
."<br>Utilisateur : ".$NomChercher
."<br>Commande : ".$cmd
."<br>Nouvel Emplacement : ".$NewChemin.'<br>';
$tps_start = get_microtime();
$resultat = shell_exec($cmd);
$tabUser = explode("\n",$resultat);
foreach ($tabUser as $ligne)
{
if(!empty($ligne))
{
$cmd = 'dsmove '.$ligne.' -newparent "'.$NewChemin.'"';
$resultat = shell_exec($cmd);
if($resultat)
$cpt ++;
else
echo '! '.$cmd.'<br>';
}
$resultat = '';
}
$tps_stop = get_microtime();
$tpsExec = $tps_stop - $tps_start;
echo '<br>'.$cpt.' Utilisateurs Modifiés';
echo '<br><b>Temps Execution</b> : '.$tpsExec;
exit(); |
Partager