Hi ,  i am having problems with a funktion call never returns from the
funktion.

The script is started from ldaptest.php with call the funktion
authenticate().
when inserting the real name and password the script stop's at the end and
dont return to ldaptest.php


system info:
linux Suse 9.0
php 4.3.5
http server is domino R 6.5.1.

//the code //

script ldaptest.php:

<?php
include "auth3.php";
if ($_COOKIE[auth] == "1") {
    $msg = "<p>You are an authorized user.</p>";
} else {
authenticate(); // the script never returns from this line
   }
echo "user = $username";
$ip = "localhost";
$dn="CN=klaus, O=oz2lpr";
$password = "fakeword";
if (!($ldap = ldap_connect($ip))) {
   die ("Could not connect to LDAP server");
}
print "connected to <b>$ip</b><br/>";
if (!($res = @ldap_bind($ldap, $dn, $password))) {
   die ("Could not bind to $dn");
}
print "user <b>$dn</b> authenticated.<br/>";
$sdn = "O=fakeword2";
$filter = "(objectclass=*)";
print "executing search...<b>DN: $sdn; Filter: $filter</b><br/>";
$sr=ldap_search($ldap, $sdn, $filter);
$info = ldap_get_entries($ldap, $sr);
print $info["count"]." entries returned<hr>";
print "<PRE>";
print_r($info);
print "</PRE>";
ldap_close($ldap);
die;
?>


script auth3.php:

<?php
function authenticate() {
if ((!$_POST[username]) || (!$_POST[password])) {
    header("Location: ask.php");
    }
$server="localhost";    //change to ip address of ldap server
$basedn="O=oz2lpr";     //change to reflect the ou and domain that your
users are in.
                  $username=$_POST['username'];
                  $password=$_POST['password'];
                  $filter = "(objectclass=*)";
                  $dn = "CN=$username,O=oz2lpr";
                        if (!($connect = ldap_connect($server))) {
                        header("Location: ask.php");
                        exit;
                        }
                        if (!($bind = @ldap_bind($connect, "$dn",
$password))) {
                        header("Location: ask.php");
                        exit;
                        } else {
                  ldap_close($connect);
setcookie("auth", "1", 0, "/", "fakeword2.dk", 0);
return $username;
}
}
?>


script ask.php:

<html>
<head>
<title>Auth User Login Form</title>
</head>
<body>
<H1>Login Form</H1>
<FORM METHOD="POST" ACTION="auth3.php">
<P><STRONG>Username:</STRONG><BR>
<INPUT TYPE="text" NAME="username"></p>
<P><STRONG>Password:</STRONG><BR>
<INPUT TYPE="password" NAME="password"></p>
<P><INPUT TYPE="SUBMIT" NAME="submit" VALUE="Login"></P>
</FORM>
</body>
</html>




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to