I am running a Debian Linux server that is hosting my Apache2 web server for an in-house web application I am developing. I am attempting to utilize LDAP for user authentication by communicating with our Active Directory server checking user info and global security groups.
On my Linux server I installed the php_ldap module using the standard apt-get:
sudo apt-get install php-ldap
I then modified my php.ini file to uncomment this extension:
extension=ldap
And add this extension:
extension=php_ldap.so
I have not altered my apache2.conf file yet as in my dev environment (which is unfortunately in Windows for now due to various constraints I’ve picked up from previous developers) the current setup works.
Besides installing the module, and enabling it in my configuration files, then lastly restarting the apache2 service on my linux server, I’m not sure what else I could be missing.
When I attempt to POST to my index.php page with the login information I get a this error:
PHP Fatal error: Uncaught Error: Call to undefined function ldap_connect()...
It is obviously not recognizing the LDAP methods I’ve implemented but for the life of me I cannot figure out why. All the googling I’ve done has led me to the same exact steps I’ve already outlined so if anyone has any additional information that could help me out I’d greatly appreciate it.
2
Answers
You can easily install
LDAP
if you are using Docker.If you don’t then I would like to encourage you to start using it. Docker works on Linux and Windows as well.
How to install Docker
Then create a text file called Dockerfile
in the same directory where is Dockerfile issue a command:
to see build images:
to run the image and enter shell type:
once you are into shell type:
and you should see list of extensions including
ldap
.type into shell
to leave it
and you may start your web server with the command:
How to use apache docker image – look for the section
php:<version>-apache
If you would like to install also other extensions see the section
How to install more PHP extensions
There are also other useful Docker images like MySQL that you may want to use as well.
First check
phpinfo()
. When PHP had not been built with flags--with-ldap
or--with-ldap-sasl
, you’ll have to build PHP from source, in order to get LDAP support with or without SASL.In case it had been enabled at build time, then package
php7.0-ldap
should suffice. Rundpkg -L php7.0-ldap
to see what and where it installs. If anything else may be required, then this may bephp -m
andphpenmod ldap
.One can apply LDAP configuration with a
/home/www-data/.ldaprc
file:https://manpages.ubuntu.com/manpages/cosmic/man5/ldap.conf.5.html