PHP
downloads | documentation | faq | getting help | mailing lists | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

yp_err_string> <yp_all
Last updated: Fri, 14 Nov 2008

view this page in

yp_cat

(PHP 4 >= 4.0.6, PHP 5 <= 5.0.5)

yp_catRetourne une tableau contenant la carte entière

Description

array yp_cat ( string $domain , string $map )

Retourne une tableau contenant toutes les entrées de la carte.

Liste de paramètres

domain

Le nom du domaine NIS.

map

La carte NIS.

Valeurs de retour

Retourne toutes les entrées de la carte sous forme de tableau associatif dont les clés et les valeurs sont respectivement les clés et les entrées de la carte.



yp_err_string> <yp_all
Last updated: Fri, 14 Nov 2008
 
add a note add a note User Contributed Notes
yp_cat
Nicholas Humfrey
22-Jan-2007 11:15
yp_cat is lacking in PHP5 - this is a suitable (slow, forking) replacement...

<?php
    $handle
= popen( 'ypcat passwd.byname', 'r' );
    while ((
$line = fgets($handle, 1024)) !== FALSE) {
        list(
$user,$pass,$uid,$gid,$gcos,$home,$shell) = explode (':', $line);
        list(
$name,$room,$work,$home,$position)  = explode (',', $gcos);

       
## Do Stuff ##

   
}  
   
pclose( $handle );
?>
20-Feb-2006 12:26
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;
}
smchang at math dot inha dot ac dot kr
21-Dec-2002 03:12
result browsing code
<?php
$arraylist
= yp_cat($domain,"passwd.byname");
$key = array_keys($arraylist);
$count = count($key);
for (
$i = 0; $i < $count ; $i++ ) {
        echo
"COUNT $i  ->  ";
        echo
$arraylist[$key[$i]];
        echo
"<BR>\n";
}
?>
RESULT( Only First line )
COUNT 0 -> testuser:3jYXqr8fRm28M:500:500:PHP Test user:/home/testuser:/bin/csh

It, is in $key, is username(in example, testuser).

yp_err_string> <yp_all
Last updated: Fri, 14 Nov 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites