# Windows Domain Authentication with Apache+Mongrel

**URL:** <https://www.ruby-forum.com/t/windows-domain-authentication-with-apache-mongrel/130789>\
**Category:** Rails\
**Created:** [March 3, 2008, 11:46am UTC](https://www.ruby-forum.com/t/windows-domain-authentication-with-apache-mongrel/130789 "2008-03-03T11:46:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eabhvee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/85f322/32.png) [@eabhvee](https://www.ruby-forum.com/u/eabhvee)\
**Post date:** [March 3, 2008, 11:46am UTC](https://www.ruby-forum.com/t/windows-domain-authentication-with-apache-mongrel/130789/1 "2008-03-03T11:46:18Z")

</div>

Hi All,

I am running a rails application in my laptop which is connected to the  
corporate intranet. I am using Apache 2.2.4 with Mongrel proxying. I  
want to authenticate the corporate intranet users using Windows  
Authentication. This is working fine with mod\_sspi but I cant retrieve  
the username in rails. Its not available in REMOTE\_USER or  
X\_FORWARDED\_USER. I have used the rewrite rule to add this information  
in the request header but with no success. When I set the request header  
like this for testing purpose,  
RequestHeader add X-FORWARDED-User “testuser”

its working fine and I can see the username but when I use this rewrite  
rule  
RewriteEngine On  
RewriteCond %{LA-U:REMOTE\_USER} (.+)  
RewriteRule . -[E=RU:%1]  
RequestHeader add X-FORWARDED-User %{RU}e  
all I get in HTTP\_X\_FORWARDED\_USER is (null).  
I know this issue has been discussed a lot and I can see people saying  
its working for them but I cant get this working. My Apache  
configuration for proxying is:-  
#########################################################  
ProxyRequests Off  
\<Proxy \*\>  
Order deny,allow  
Allow from all  
RewriteEngine On  
RewriteCond %{LA-U:REMOTE\_USER} (.+)  
RewriteRule . -[E=RU:%1]  
RequestHeader add X-FORWARDED-User %{RU}e

Alias /rca “c:/IIS/rca/public”

\<Directory “C:/IIS/rca/public”\>  
Options Indexes FollowSymLinks  
AllowOverride none  
Order allow,deny  
Allow from all

ProxyPass /rca/images !  
ProxyPass /rca/stylesheets !  
ProxyPass /rca/javascripts !  
ProxyPass /rca/ [http://127.0.0.1:4000/](http://127.0.0.1:4000/)  
ProxyPass /rca [http://127.0.0.1:4000/](http://127.0.0.1:4000/)  
ProxyPassReverse /rca/ [http://127.0.0.1:4000/](http://127.0.0.1:4000/)  
############################################################

Here is the list of enviornment variables printed in rails.  
##############################################################  
SERVER\_NAME 127.0.0.1  
HTTP\_MAX\_FORWARDS 10  
PATH\_INFO  
HTTP\_X\_FORWARDED\_HOST localhost  
HTTP\_ACCEPT\_ENCODING gzip,deflate  
HTTP\_USER\_AGENT Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;  
rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6  
SCRIPT\_NAME /  
SERVER\_PROTOCOL HTTP/1.1  
HTTP\_ACCEPT\_LANGUAGE en-us,en;q=0.5  
HTTP\_HOST 127.0.0.1:4000  
REMOTE\_ADDR 127.0.0.1  
SERVER\_SOFTWARE Mongrel 1.1.3  
REQUEST\_PATH  
HTTP\_X\_FORWARDED\_USER (null)  
HTTP\_ACCEPT\_CHARSET ISO-8859-1,utf-8;q=0.7,_;q=0.7  
HTTP\_VERSION HTTP/1.1  
HTTP\_X\_FORWARDED\_SERVER E001B784E228A  
REQUEST\_URI /  
SERVER\_PORT 4000  
GATEWAY\_INTERFACE CGI/1.2  
HTTP\_X\_FORWARDED\_FOR 0.0.0.0  
HTTP\_ACCEPT text/xml,application/xml,  
application/xhtml+xml,  
text/html;q=0.9,  
text/plain;q=0.8,image/png,_/\*;q=0.5  
HTTP\_CONNECTION Keep-Alive  
REQUEST\_METHOD GET  
###########################################################

Any help is appreciated.

Regards,  
Abhi
