I have an .htaccess file that authenticates users against LDAP using mod_auth_ldap. My requirement is to somehow store their username and use it elsewhere**. I think I may be able to do it with mod_rewrite and cookies.
AuthBasicProvider ldap
AuthType Basic
AuthName "xxx"
AuthzLDAPAuthoritative off
AuthLDAPUrl "xxx" NONE
AuthLDAPBindDN "xx"
AuthLDAPBindPassword xx
Require valid-user
—
RewriteCond %{HTTP_COOKIE} !(username)
RewriteRule ^(.*)$ - [L,CO=username:%{USERNAME}:.domain.com]
If anyone wants to tell me cookies is a rubbish idea and has a better one, please do.
Many thanks.
** I note there are security implications by using a username from a cookie but in my app this acceptable.
The magic variable was %{REMOTE_USER}.