Problems with Secure Bind to Active Directory Using PHP

Problems with secure bind to Active Directory using PHP

As my code is working fine with CentOS, I conclude that the problem is not programming specific. I have not been able to get it running in my Ubuntu environment as of yet, but I assume this is a bug in my server software.

PHP ldap connection always turns out true

You are right, there is probably something wrong with the api, it always returns true. That's the working implementation that we used.

    define('LDAP_OPT_DIAGNOSTIC_MESSAGE', 0x0032);
$conn = "ldap://whatever.com"; //
$port = "389"; // by default port 389
$version = "3"; // by default 3
$referral = "0"; // by default 0
$user = "username";
$password = "password";

if ($user && $password) {
//Connect LDAP Server
echo " connecting to ldap mdec<br/> ";
$connect = ldap_connect($conn, $port);
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, $version);
ldap_set_option($connect, LDAP_OPT_REFERRALS, $referral);

$bind = ldap_bind($connect, $user, $password);
if ($bind) {
echo "OK. ";
} else {
echo "couldn't bind.";
if (ldap_get_option($connect, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extended_error)) {
echo "Error connecting to LDAP: $extended_error";
} else {
echo "Error connecting to LDAP: No additional information is available.";
}
}
ldap_close($connect);
} else {
echo "in else, do whatever you want to show to the user";
}


Related Topics



Leave a reply



Submit