i have to code an authentication module for our intranet area. I started with a simple html form collecting the two credentials (username and upasswd) which is to be send to the 'authenticate.inc':
Code: Select all
<?php
require('departments.inc');
$username = $_REQUEST["username"];
$upasswd = $_REQUEST["upasswd"];
if (($username=='') && ($upasswd=='')) {
$login = "false";}
else if (($username=='') && ($upasswd != '')) {
$login = "false";}
else if (($username != '') && ($upasswd=='')) {
$login = "false";}
else if (($username != '') && ($upasswd != '')) {
$login = "true";}
if ($login=='false') {
header("HTTP/1.0 401 Unauthorized");
header ("Location: /shared/docs/system/messages/401.php3");}
else if ($login=='true') {
$salt = substr($upasswd , 0, 1);
$passwd = crypt("'$upasswd', '$salt'");
require('ldap_connect.ldp');
if ($ds) {
$ldapbind = ldap_bind($ds);
if ($ldapbind) {
$dn = "ou=people,dc=my dc=home,dc=de";
$filter = "(&(uid=$username) (userPassword=$passwd))";
$get_userid = array("uid", "userPassword", "uidNumber");
$sr01 = ldap_search($ds, $dn, $filter, $get_userid);
$entries_returned01 = ldap_count_entries($ds,$sr01);
if ($entries_returned01=='0') {
header("HTTP/1.0 401 Unauthorized");
header ("Location: /intra/index.php3?department=$department&LANG=$LANG&view=$view");}
else if ($entries_returned01=='1') {
$entry01 = ldap_first_entry($ds, $sr01);
$values01 = ldap_get_values($ds, $entry01, "uidNumber");
$suserid = $values01[0];
$userid = "$suserid";
$lquery = "SELECT staff_ldap.ldap_s01, staff_ldap.ldap_s02, DBstaff.staff_ldap.ldap_s05 FROM staff_ldap WHERE staff_ldap.ldap_s03 = '$userid' AND staff_ldap.ldap_s04 = '$username' LIMIT 0,1";
$lerg = mysql_query($lquery);
$lnumrows = mysql_num_rows($lerg);
if ($lnumrows=='1') {
$l = 0;
$sectionID = mysql_result($lerg,$l,"ldap_s01");
$login = mysql_result($lerg,$l,"ldap_s02");
$user = mysql_result($lerg,$l,"ldap_s05");
header ("Location: /intra/login/index.php3?department=$department&LANG=$LANG&view=$view§ionID=$sectionID&login=$login&user=$user&username=$username");}}
else {
header("HTTP/1.0 401 Unauthorized");
header ("Location: /intra/index.php3?department=$department&LANG=$LANG&view=$view");}
$ldapunbind = ldap_unbind($ds);}}}
?>My Problem lies in line 30 / 31. The manual attached to our LDAP implementation (a SunOne Directory Server) says that while adding a new user, his password will be Standard UNIX encrypted, and the PHP manual says that crypt() uses the Standard UNIX crypt function. Butr when i use PHP crypt as a standalone function
Code: Select all
<?php
$passwd = crypt('teststringfordummiesliekeme', 't');
echo $passwd;
?>Any hints?
Greetings,
- bluenote