Php – How to get LDAP to pass the currently logged-in user’s credentials to a local Apache server

apache-2.4ldapPHPwindows 7

I'm trying to get SSO (single-sign on) working on a local osTicket installation. I found the HTTP passthru plugin on the osTicket website and have installed it in osTicket. I've made sure the plugin is working by making sure I have access to the plugin settings. So what should happen, as I understand it, is that the user's credentials is read from Windows and then passed directly into osTicket so that the user is automatically logged in. Please correct me if I'm wrong about how the plugin should work. I also made sure that the LDAP plugin is working and installed in osTicket. I did some research on why the automatic login was not working, and realized that HTTP authentication was not the same as Windows AD authentication. I looked up SSPI, Kerberos, and more to see if I could get Windows credentials to the Apache server and assumed that the LDAP module should be able to get those credentials. Again, please correct me if I'm wrong about how the LDAP module works. Eventually, I just nuked my XAMPP install and started over with a WAMP installation. Got LDAP working on that and now I'm trying to find a way to get credentials to Apache. I've written a simple script that is supposed to echo the currently logged in user.

<?php
$user = $_SERVER['REMOTE_USER'];
?>
<html>
<body>
<?php echo $user;?>
</body>
</html>

However, when I run this script I get the following error.

( ! ) Notice: Undefined index: REMOTE_USER in C:\wamp\www\servertest.php on line 2

This tells me that the superglobal for $_SERVER is not getting Windows credentials for the currently connected user. How can I fill in this superglobal array with Windows credentials? Are there any configuration options that need to be added to my HTTPD.conf?

Best Answer

you need to configure your wamp installation for ldap and/or kerberos authentication and those variables will be available to your php scripts.

For Apache 2.2 (most commonly found today): http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html

For Apache 2.4: http://httpd.apache.org/docs/2.4/mod/mod_authnz_ldap.html

If you require single sign on, then you will need to configure mod_kerberos as well. I have never used xampp or wamp so I have no idea if they have mod_kerberos.

If you want something that just works without having to learn how it works, then you can install IIS as you are running Windows anyway. A non home modern version of Windows desktop will allow to run it with some restrictions on the number of simultaneous connections, whereas a server version will not have that limitation.