search

Home  >  Q&A  >  body text

ldap_bind reports an error, please solve it

Dear heroes, every time I run $bd=ldap_bind($conn,$user,$password);//During user verification, if True, the IF statement will be run, but if it is wrong, it will not "Binding failed" in the IF will be displayed, but the following error will be displayed. What is the reason? Thank you.

PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in J:\ReportData\ltest.php on line 13

The source code is as follows:

                  <?php

$host="172.27.108.1";

$port='389';

$ domain='globalnet';

$account='testuser1';

$password='P@ssw0rd01';

$user="{$account}@{ $domain}";

$conn=ldap_connect($host,$port);

if($conn){

ldap_set_option($ conn,LDAP_OPT_PROTOCOL_VERSION,3) or die ("Could not set LDAP Protocol version");//Declaration to use version 3

ldap_set_option($conn,LDAP_OPT_REFERRALS,0);//Binding to ldap server

$bd=ldap_bind($conn,$user,$password);//User verification

if($bd){

echo 'LDAP binding successful';

}

else

{

echo 'Binding failed';

}

} else{

echo 'Unable to connect'; #

齐格飞啊飞齐格飞啊飞1140 days ago1200

reply all(2)I'll reply

No reply
  • Cancelreply