I hope this will userfull to somebody:
function auth_by_nis($login,$password,$nis_domain='-d xxx_nis',$nis_host='-h xxx.it')
{
$output = shell_exec("ypcat $nis_domain $nis_host passwd");
$lines=split("\n",$output);
foreach ($lines as $k=>$v)
{
list($login_nis,$pw_nis)=split(":",$v);
if ($login_nis != $login)continue;
//login trovata: ora si verifica la password
$salt=substr( $pw_nis , 0 ,2);
$pass_cript=crypt($password, $salt);
if($pass_cript == $pw_nis) return 1;
else return 0;
}
return 0;
}