PHP Warning: ldap_bind (): cannot communicate with server: cannot communicate with LDAP server

I have a problem with my php script:

PHP Warning: ldap_bind (): Cannot bind to server: cannot connect to LDAP server ....

ldap_connect() says “ ldap_bind() ”, but ldap_bind() fails, how to fix this problem?

+8
php ldap
source share
5 answers

Connection opens a session. Bind is what really authenticates you. This way you are connected but not logged in with valid credentials.

+7
source share

If this error is on RHEL7 (CentOS7) due to restrictions prohibiting SELinux, HTTPD can be used.

In the list of allowed default LDAP ports 389 and 636, you can unlock:

 setsebool -P httpd_can_network_connect 1 

You can test the restriction by trying the socket on the LDAP server:

 fsockopen('LDAP-Server-IP', 389); 

He will give "Permission Denied", indicating that he is blocked, not a question.

Also check the SELinux audit log file to block other things.

+3
source share

I have no experience that matches what I read here. I tried

 $ds=ldap_connect("goblydeegook",336); if($ds) echo "successful"; 

and I get a "successful" answer

+2
source share

Sometimes the problem will depend on your environment (Linux, Windows ...) Try to associate with one of the following options:

 $connect = ldap_connect("ldap://".$ldap_server); $auth_user = 'CN=XXX,OU=XXX,DC=XXX,DC=com'; $bind = ldap_bind($connect, $auth_user , $auth_pass); 

or

 $bind = ldap_bind($connect, 'YourDomaine\\'.$auth_user , $auth_pass); 
0
source share

The ldap_bind () function requests three parameters:

  • resource id
  • a rdn
  • password associated with rdn, rdn and password are optional

if you link using only the resource identifier: -

 // $ldap=ladap_connect(*hostname*,*port*); // ldap_connect() returns a resource id ldap_bind() returns a boolean value(true or false) ldap_bind($ladp); //annonymous bind $lb=ldap_bind($ldap,"uid=xxx,ou=something,o=hostname.com","password"); //used to authenticate 

this should work, if not, then you are using invalid credentials.

-2
source share

All Articles