Hello Mark,
first of all, thank you (all) a lot for your contributions...
>Are you sure you are connecting? As in, do you only try to bind if you
>have
>a successful connection?
(...) I try to bind only when the connection itself is established...
>Have you checked ldap_error?
"Can't contact LDAP server", it says....
>Are you doing an anonymous bind, or using a username and password? Try
>each
>and see what happens
Both methods fail regarding my login-script, again, the test script
works fine on both.
>How about posting some code?
...sorry... here they come, first the testscript and then the extract
from the login script
$ldaphost = $_REQUEST["ldaphost"];
$ldapport = $_REQUEST["ldapport"];
$ds = ldap_connect($ldaphost, $ldapport)
or die("Could not connect to $ldaphost"."<br />");
if (ldap_get_option($ds, LDAP_OPT_PROTOCOL_VERSION, $version))
echo "Sie benutzen die Protokollversion $version"."<br />";
else
echo "Protokollversion konnte nicht bestimmt werden"."<br />";
if (ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3))
echo "Verwenden von LDAPv3"."<br />";
else
echo "Kann das Protokoll nicht auf Version 3 setzen"."<br />";
if ($ds) {
$username = $_REQUEST["ldapuser"];
$binddn = 'uid='.$username.', ou=users, ou=OxObjects, dc=dbusiness,
dc=de';
$ldapbind = ldap_bind($ds, $binddn, $_REQUEST["ldappass"]);
if ($ldapbind) {
print "Congratulations! You are authenticated. <br />";
print "".$_REQUEST["ldapuser"];}
else {
print "Nice try, kid. Better luck next time! <br />";
}
}
Here is the login part, as you see it does not differ much from the
testscript...
if (!empty($_REQUEST["IO_username"])) {
$ldaphost = LDAP_HOST;
$ldapport = LDAP_PORT;
$ds = ldap_connect($ldaphost, $ldapport)
or die("Could not connect to $ldaphost"."\n");
if (ldap_get_option($ds, LDAP_OPT_PROTOCOL_VERSION, $version))
echo "Sie benutzen die Protokollversion $version"."\n";
else
echo "Protokollversion konnte nicht bestimmt werden"."\n";
if (ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3))
echo "Verwenden von LDAPv3"."\n";
else
echo "Kann das Protokoll nicht auf Version 3 setzen"."\n";
if ($ds) {
$username = $_REQUEST["IO_username"];
$upasswd = $_REQUEST["IO_password"];
$binddn =
'uid='.$username.',ou=users,ou=OxObjects,dc=dbusiness,dc=de';
$ldapbind = ldap_bind($ds, $binddn, $upasswd);
if ($ldapbind) {
print "User is authenticated... \n";
print "".$binddn."\n";
$DB_checkuserid->query("SELECT * FROM users_users WHERE
username='".$HTTP_POST_VARS["IO_username"].
"' AND
password='".$HTTP_POST_VARS["IO_password"]."';");
if ($DB_checkuserid->rows == 1) {
$thisuser = $DB_checkuserid->fetch(0);
$HTTP_SESSION_VARS["userid"] =
$HTTP_POST_VARS["IO_username"];
$HTTP_SESSION_VARS["userfullname"] =
$thisuser["fullname"];
$HTTP_SESSION_VARS["usergroupid"] = $thisuser["groupid"];
}
} else {
var_dump($ds);print " <br />\n";
var_dump($ldapbind);print " <br />\n";
print "Error: ".ldap_error($ds)." <br />\n";
print "DN: ".$binddn." <br />\n";
print "pwd: ".$upasswd." <br />\n";
print "Nice try, kid. Better luck next time! <br />";
die ("LDAP authentication error! Check username and/or
password !");
}
} else {
print "Nice try, kid. Better luck next time! <br />";
die ("LDAP connection error! Please inform the administrator !");
}
}
>I have just spent several days trying on and off to work out LDAP, from
>a
>starting position of "what's LDAP?".
I had the same problem with the testscript once, then left it off
several days/some weeks
satisfying my boss with a mySQL-based login. now the testscript works
without doing any changes...
Björn Bartels
-Development/IT-Services-
----------------------------------------------
dbusiness.de gmbh
digital business & printing gmbh
Greifswalder Str. 152
D-10409 Berlin
Fon: [0.30] 4.21.19.95
Fax: [0.30] 4.21.19.74
www.dbusiness.de
[EMAIL PROTECTED]
ftp://dbusiness.dyndns.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php