LLDAP, PHP, CORS error
# troubleshooting
k
Hello, I setup a small website using php and ldap_connect. Everything is working great on my local network (using a port redirect from http://my-wan-ip:4200 to the local LLDAP at port 3890). Then, i move the webpages to my remote hosting (OVH) and when try to login, i have a CORS error. I try a dirty quick fix using : header("Access-Control-Allow-Origin: *"); CORS error is gone, but still get an Error 500, and visibly, my webserver is unable to communicate to LLDAP, because ldap_connect or ldap_bind did not generate any error. I can access the webUI from the internet (http://my-wan-ip:4201 which redirect to LLDAP port 17170) So, i think LLDAP is reachable from the Internet, my code is correct because working locally. But this is the first time i use a LDAP connection from a hosting platform, so i must miss something, but can't find out what. Did anyone encounter the same issue ? Thanks
n
Here's a brand new thread for you! Please keep the discussion for this problem in this thread.
k
Here the log from outside vs local network. The HTTP request is received but that is all I use this simple script : ```<?php header("Access-Control-Allow-Origin: *"); $ldapuri = "ldap://my-domain.ext:4200"; $ldap_dn = "uid=test,ou=people,dc=domain,dc=com"; $ldap_password = "password"; $ldapconn = ldap_connect($ldapuri) or die("That LDAP-URI was not parseable"); ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3); if ($ldapconn) { $ldapbind = ldap_bind($ldapconn, $ldap_dn, $ldap_password); if ($ldapbind) echo "LDAP bind successful...\n"; else echo "LDAP bind failed...\n"; } ldap_close($ldapconn); ?>
n
Hmm. To quote the LLDAP logs: "Success". You could bind successfully and then sent an unbind request
k
I only have the status_code 200 from the outside, not the success
n
Oh right. Are you sure the domain and port are correct?
Oh, that's the cors thing you mentioned
k
Well, i can't be sure 100%, but it seems good to me
n
Yeah, I'm not sure about that. Although that should run from php in the backend, cors should have nothing to do there
k
only get a error 500, so it is not really helpful
n
Sorry, I've never used the php LDAP library
k
Yeah, i understood that last time, don't worry
I think the problem is with my hosting, because, even with local server + 4G connection, it works
So i guess, the issue is not "the outside", but the hosting service
After more research, i can confirm that my hosting did not support LDAP, so i understand the issue 😦
Easy way to check : if (!function_exists('ldap_connect')) { die('Your server does not support LDAP'); }