NIS functionsNIS
NIS (formerly called Yellow Pages) allows network management of
important administrative files (e.g. the password file). For more
information refer to the NIS manpage and
Introduction to YP/NIS. There is also a book called Managing NFS and NIS by Hal Stern.
To get these functions to work, you have to configure PHP with
.
yp_get_default_domainFetches the machine's default NIS domain.Descriptionint yp_get_default_domainvoid yp_get_default_domain returns the default
domain of the node or FALSE. Can be used as the domain parameter
for successive NIS calls.
A NIS domain can be described a group of NIS maps. Every host
that needs to look up information binds itself to a certain
domain. Refer to the documents mentioned at the beginning for
more detailed information.
Example for the default domain
<?php
$domain = yp_get_default_domain();
echo "Default NIS domain is: " . $domain;
?>
yp_orderReturns the order number for a map.Descriptionint yp_orderstring domainstring mapyp_order returns the order number for a map
or FALSE.
Example for the NIS order
<?php
$number = yp_order($domain,$mapname);
echo "Order number for this map is: " . $order;
?>
See also yp-get-default-domain.
yp_masterReturns the machine
name of the master NIS server for a map.Descriptionstring yp_masterstring domainstring mapyp_master returns the machine name of
the master NIS server for a map.
Example for the NIS master
<?php
$number = yp_master($domain, $mapname);
echo "Master for this map is: " . $master;
?>
See also yp-get-default-domain.
yp_matchReturns the matched line.Descriptionstring yp_matchstring domainstring mapstring keyyp_match returns the value associated with
the passed key out of the specified map or FALSE. This key must
be exact.Example for NIS match
<?php
$entry = yp_match($domain, "passwd.byname", "joe");
echo "Matched entry is: " . $entry;
?>
In this case this could be: joe:##joe:11111:100:Joe
User:/home/j/joe:/usr/local/bin/bash
See also yp-get-default-domainyp_first Returns the first key-value pair from the named
map.Descriptionstring[] yp_firststring domainstring mapyp_first returns the first key-value
pair from the named map in the named domain, otherwise FALSE.
Example for the NIS first
<?php
$entry = yp_first($domain, "passwd.byname");
$key = key($entry);
echo "First entry in this map has key " . $key
. " and value " . $entry[$key];
?>
See also yp-get-default-domainyp_nextReturns the next key-value pair in the named
map.Descriptionstring[] yp_nextstring domainstring mapstring keyyp_next returns the next key-value pair in
the named map after the specified key or FALSE.
Example for NIS next
<?php
$entry = yp_next($domain, "passwd.byname", "joe");
if(!$entry) {
echo yp_errno() . ": " . yp_err_string();
}
$key = key($entry);
echo "The next entry after joe has key " . $key
. " and value " . $entry[$key];
?>
See also yp-get-default-domain.