PHP/LDAP simple function doesn't work
Posted: Wed Oct 08, 2008 4:56 pm
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
I'm new to PHP/LDAP. And tried to use LDAP bind function:ldap_bind().
The weird thing is if I use anonymous bind, it shows:
LDAP bind successful...
However, if I give my credentials (my username and password), it always display warning message:
Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Inv
alid credentials in C:\wamp\virtual\wga\itest2\www\ldapConnect\bindTest.php on line 13
LDAP bind failed...
Here is my very simple code:
Can somebody tell me what's wrong? I also noticed when I check my phpinfo(), PHP Version 5.2.5, it shows:
LDAP Support: enabled
RCS Version: $Id: ldap.c,v 1.161.2.3.2.11 2007/07/17 09:09:42 jani Exp $
Total Links: 0/unlimited
API Version: 2004
Vendor name: OpenLDAP
Vendor Version: 0
WHY the vendor version is 0? Is than an error? if it is, is it due to the wrong configuration? What's the fix? Does this error caused my LDAP function not working properlly?
Thanks, I'm really frustrated now.
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
I also re-numbered your IP - assuming you don't want the world to contact that IP.
I'm new to PHP/LDAP. And tried to use LDAP bind function:ldap_bind().
The weird thing is if I use anonymous bind, it shows:
LDAP bind successful...
However, if I give my credentials (my username and password), it always display warning message:
Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Inv
alid credentials in C:\wamp\virtual\wga\itest2\www\ldapConnect\bindTest.php on line 13
LDAP bind failed...
Here is my very simple code:
Code: Select all
<?php
$host = 'ldaps://123.45.67.89'; //I provide the IP address of AD controller
// using ldap bind
$ldaprdn = ''; // ldap rdn or dn
$ldappass = ''; // associated password
$ldapconn = ldap_connect($host)
or die("Could not connect to LDAP server.");
if ($ldapconn) {
// binding to ldap server
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
// verify binding
if ($ldapbind)
{
echo "LDAP bind successful...<br />";
} else {
echo "LDAP bind failed...";
}
}
// all done? clean up
ldap_close($ldapconn);
?>LDAP Support: enabled
RCS Version: $Id: ldap.c,v 1.161.2.3.2.11 2007/07/17 09:09:42 jani Exp $
Total Links: 0/unlimited
API Version: 2004
Vendor name: OpenLDAP
Vendor Version: 0
WHY the vendor version is 0? Is than an error? if it is, is it due to the wrong configuration? What's the fix? Does this error caused my LDAP function not working properlly?
Thanks, I'm really frustrated now.
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
I also re-numbered your IP - assuming you don't want the world to contact that IP.