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
Php: What Is the Purpose of Session_Name
Adding User Custom Field Value to Order Items Details
Fatal Error: Class 'Xsltprocessor' Not Found
In Simplexml, How to Add an Existing Simplexmlelement as a Child Element
Check If Method Exists in the Same Class
Http Auth via PHP - PHP_Auth_User Not Set
Why Ob_Start() Must Come Ahead of Session_Start() to Work in PHP
Strpos() with Multiple Needles
Php: How to Add Leading Zeros/Zero Padding to Float via Sprintf()
Woocommerce: Display Also Product Variation Description on Cart Items
Easiest Way to Implode() a Two-Dimensional Array
PHP - Is "Include" Function Secure
PHP Post Limited to 1000 Variables