# Rails equivalent of IIS' request.ServerVariables?

**URL:** <https://www.ruby-forum.com/t/rails-equivalent-of-iis-request-servervariables/72327>\
**Category:** Rails\
**Created:** [October 16, 2006, 2:33pm UTC](https://www.ruby-forum.com/t/rails-equivalent-of-iis-request-servervariables/72327 "2006-10-16T14:33:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [October 16, 2006, 2:33pm UTC](https://www.ruby-forum.com/t/rails-equivalent-of-iis-request-servervariables/72327/1 "2006-10-16T14:33:42Z")

</div>

Does anyone have a methodology for accessing the Windows Network ID of  
the logged in user from within a Rails application?

My company has an IIS/asp framework for its intranet. All those pages  
make use of the ServerVariables data embedded in the Request object to  
access the user name of the logged-in network user, as in:

Request.ServerVariables(“LOGON\_USER”)

Apparently ServerVariables is something that IIS wraps into the Request  
object. I need something equivalent in Rails, or I’ll never be able to  
get traction with RoR here.

Any ideas?

Thanks.  
c.

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [October 16, 2006, 2:46pm UTC](https://www.ruby-forum.com/t/rails-equivalent-of-iis-request-servervariables/72327/2 "2006-10-16T14:46:31Z")

</div>

Cayce B. wrote:

> object. I need something equivalent in Rails, or I’ll never be able to  
> get traction with RoR here.
> 
> Any ideas?

Server variables are just a derivative of Environment variables. Those  
are accessible through Ruby, and hence Rails.

–  
_Berin L._  
Owner

_Work:_ 571-215-7708  
_Email:_ removed\_email\_address@domain.invalid [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
_IM:_ removed\_email\_address@domain.invalid (MSN)  
\*[http://www.linkedin.com/in/bloritsch](http://www.linkedin.com/in/bloritsch)  
\*

- 
  - 

```
	*D-Haven* <http://d-haven.org>

```

20044 Great Falls Forest Dr.  
[http://maps.google.com/maps?q=20044+Great+Falls+Forest+Dr.%2CGreat+Falls%2CVA+22066%2CUSA&hl=en](http://maps.google.com/maps?q=20044+Great+Falls+Forest+Dr.%2CGreat+Falls%2CVA+22066%2CUSA&hl=en)  
Great Falls, VA 22066  
USA

See who we know in common [http://www.linkedin.com/e/wwk/5678360/](http://www.linkedin.com/e/wwk/5678360/) Want  
a signature like this? [http://www.linkedin.com/e/sig/5678360/](http://www.linkedin.com/e/sig/5678360/)

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [October 16, 2006, 3:38pm UTC](https://www.ruby-forum.com/t/rails-equivalent-of-iis-request-servervariables/72327/3 "2006-10-16T15:38:31Z")

</div>

Not sure I understand what you mean. The ServerVariables collection is  
added into the request object by IIS. IIS is somehow able to determine  
who the logged in user making the browser request is, and adds that into  
the header request.

My rails application is on a Linux box. What environment variable do I  
access to determine who the logged in user making the browser request  
is?

thanks.  
c.

Berin L. wrote:

> Cayce B. wrote:
> 
> > object. I need something equivalent in Rails, or I’ll never be able to  
> > get traction with RoR here.
> > 
> > Any ideas?
> 
> Server variables are just a derivative of Environment variables. Those  
> are accessible through Ruby, and hence Rails.
> 
> –  
> _Berin L._  
> Owner
> 
> _Work:_ 571-215-7708  
> _Email:_ removed\_email\_address@domain.invalid [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> _IM:_ removed\_email\_address@domain.invalid (MSN)  
> \*[http://www.linkedin.com/in/bloritsch](http://www.linkedin.com/in/bloritsch)  
> \*
> 
> - 
> - 
> 
> ```
> *D-Haven* <http://d-haven.org>
> 
> ```
> 
> 20044 Great Falls Forest Dr.  
> [http://maps.google.com/maps?q=20044+Great+Falls+Forest+Dr.%2CGreat+Falls%2CVA+22066%2CUSA&hl=en](http://maps.google.com/maps?q=20044+Great+Falls+Forest+Dr.%2CGreat+Falls%2CVA+22066%2CUSA&hl=en)  
> Great Falls, VA 22066  
> USA
> 
> See who we know in common [http://www.linkedin.com/e/wwk/5678360/](http://www.linkedin.com/e/wwk/5678360/) Want  
> a signature like this? [http://www.linkedin.com/e/sig/5678360/](http://www.linkedin.com/e/sig/5678360/)

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [October 16, 2006, 9:19pm UTC](https://www.ruby-forum.com/t/rails-equivalent-of-iis-request-servervariables/72327/4 "2006-10-16T21:19:04Z")

</div>

Cayce B. wrote:

> Does anyone have a methodology for accessing the Windows Network ID of  
> the logged in user from within a Rails application?
> 
> My company has an IIS/asp framework for its intranet. All those pages  
> make use of the ServerVariables data embedded in the Request object to  
> access the user name of the logged-in network user, as in:
> 
> Request.ServerVariables(“LOGON\_USER”)
> 
> Apparently ServerVariables is something that IIS wraps into the Request  
> object. I need something equivalent in Rails, or I’ll never be able to  
> get traction with RoR here.

Not sure if this is what you need, but the request method has a lot of  
information in it. Maybe it’ll be useful to you.

In a view:

\<%= debug(request) %\>

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [October 16, 2006, 6:45pm UTC](https://www.ruby-forum.com/t/rails-equivalent-of-iis-request-servervariables/72327/5 "2006-10-16T18:45:38Z")

</div>

Your company’s IIS servers are most likely using Windows authentication.  
There are Apache modules for doing the same thing. Look for  
mod\_auth\_ntlm or whatever it’s called, and/or mod\_auth\_sspi or google  
apache and “active directory” for starters.

I’m not an IIS person, so I don’t know whether IIS can pick up usernames  
passively, but that alone would seem to be very lax security. Most  
likely the app is logging people in (even if doing so invisibly).

If making users log in separately to your apps is a concern even once  
you’re logging them in using a domain or AD, one way to go would be to  
deploy your apps with Mongrel and proxy them through one of the  
authorized IIS servers, letting IIS handle the authentication, but in  
this case you’d be running the app itself with no security, so locking  
down access to ir from everything but the authorized IIS server would be  
mighty important.

Cayce B. wrote:

> Not sure I understand what you mean. The ServerVariables collection is  
> added into the request object by IIS. IIS is somehow able to determine  
> who the logged in user making the browser request is, and adds that into  
> the header request.
> 
> My rails application is on a Linux box. What environment variable do I  
> access to determine who the logged in user making the browser request  
> is?
> 
> thanks.  
> c.
> 
> Berin L. wrote:
> 
> > Cayce B. wrote:
> > 
> > > object. I need something equivalent in Rails, or I’ll never be able to  
> > > get traction with RoR here.
> > > 
> > > Any ideas?
> > 
> > Server variables are just a derivative of Environment variables. Those  
> > are accessible through Ruby, and hence Rails.
> > 
> > –  
> > _Berin L._  
> > Owner
> > 
> > _Work:_ 571-215-7708  
> > _Email:_ removed\_email\_address@domain.invalid [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > _IM:_ removed\_email\_address@domain.invalid (MSN)  
> > \*[http://www.linkedin.com/in/bloritsch](http://www.linkedin.com/in/bloritsch)  
> > \*
> > 
> > - 
> > - 
> > 
> > ```
> > *D-Haven* <http://d-haven.org>
> > 
> > ```
> > 
> > 20044 Great Falls Forest Dr.  
> > [http://maps.google.com/maps?q=20044+Great+Falls+Forest+Dr.%2CGreat+Falls%2CVA+22066%2CUSA&hl=en](http://maps.google.com/maps?q=20044+Great+Falls+Forest+Dr.%2CGreat+Falls%2CVA+22066%2CUSA&hl=en)  
> > Great Falls, VA 22066  
> > USA
> > 
> > See who we know in common [http://www.linkedin.com/e/wwk/5678360/](http://www.linkedin.com/e/wwk/5678360/) Want  
> > a signature like this? [http://www.linkedin.com/e/sig/5678360/](http://www.linkedin.com/e/sig/5678360/)
