Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Authenticating *NIX users.

Status
Not open for further replies.

Caradog

Programmer
Jun 28, 2000
73
GB
I don't think this is possible but if you could proove me wrong I'd be grateful!

I want to be able to authentic users logged into a UNIX domain. I could so something similar on NT boxes, but could I read this information from a web site hosted on the same box as the accounts list??? Jace Hayman
jace@swig-online.co.uk
 
This should help you out. PHP 3/4 should have yp enabled in order to use the yp functions. Just supply the user's logon id, and password (from a form or other function...) and the function will verify the user and password against the NIS.

Function verifyPassword ($user_id, $user_password)
{
$result = 0;
$domain = yp_get_default_domain();
if ($pw_entry = yp_match ($domain, "passwd.byname", $user_id))
{
// User found.
$values = explode(":",$pw_entry);
$stored_password = trim($values[1]);
$salt = substr($stored_password, 0, 2);
$crypted_password = crypt($user_password,$salt);
if (!strcmp($stored_password, $crypted_password))
{
// password match
$result = 1;
}
}
return $result;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top