Background
I have an Apache/2.2.15 (Win32) with PHP/5.3.2 set up, handling authentication.
<Directory /usr/www/myhost/private>
# core authentication and mod_auth_basic configuration
# for mod_authn_dbd
AuthType Basic
AuthName "My Server"
AuthBasicProvider dbd
# core authorization configuration
Require valid-user
# mod_authn_dbd SQL query to authenticate a user
AuthDBDUserPWQuery "SELECT Password,UserName,Realm,Access FROM authn WHERE user = %s"
</Directory>
The authentication works fine! No problems.
But regarding to the documentation, any extra field returned back from the AuthDBDUserPWQuery will be put into an AUTHENTICATION_fieldname variable in the Environment.
With phpinfo()
, I can see these variables with he correct values under "Apache Environment".
AUTHENTICATE_USERNAME
AUTHENTICATE_REALM
AUTHENTICATE_ACCESS
Problem
I can't fetch those environment variables from my php.
1 <?php
2 $Access = apache_getenv('AUTHENTICATE_ACCESS',true);
3 var_dump($Access);
4 ?>
Line 3 prints bool(false) indicating that the variable wasn't found!
However if I change to another Apache Environment variable such as 'HTTP_HOST' it works.
..and yes, I have tried getenv()
also, same result.
There is also a note that the Apache server needs to be compiled with APR 1.3.0 to work. I used the Apache msi build from httpd.apache.org and it seems to be compiled with APR above version 2. Since I can see them with phpinfo()
they must be accessible from PHP.