# Windows username of user

**URL:** <https://www.ruby-forum.com/t/windows-username-of-user/83187>\
**Category:** Rails\
**Created:** [January 24, 2007, 7:14am UTC](https://www.ruby-forum.com/t/windows-username-of-user/83187 "2007-01-24T07:14:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![athind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@athind](https://www.ruby-forum.com/u/athind)\
**Post date:** [January 24, 2007, 7:14am UTC](https://www.ruby-forum.com/t/windows-username-of-user/83187/1 "2007-01-24T07:14:22Z")

</div>

Hello,

I am writing a Ruby on Rails application with Flex as the front end.

The RoR is installed on linux and Flash UI interacting with Rails via  
HTTPService is running on Windows.

I need to find the windows loginname of the user using my application to  
perform some basic authentication, and perhaps display Hello   
too. 🙂

Could you please let me know how that could be made possible.

Many Thanks in advance,  
Aman

---

<div class="post-metadata">

**Author:** ![athind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@athind](https://www.ruby-forum.com/u/athind)\
**Post date:** [January 24, 2007, 8:00am UTC](https://www.ruby-forum.com/t/windows-username-of-user/83187/2 "2007-01-24T08:00:37Z")

</div>

Hi Aman,

I don’t know how to do it from Flash (and thus Flex). I doubt it’s  
possible to do in straight ActionScript. That said, if it is possible  
to use JavaScript to get it, you can have JavaScript get it and then  
tell Flex via the Flex-Ajax Bridge  
([http://labs.adobe.com/wiki/index.php/Flex\_Framework:FABridge](http://labs.adobe.com/wiki/index.php/Flex_Framework:FABridge)).

Since I’m not a JavaScript / ActiveX guru, I don’t know if this is  
possible. One solution I have seen from googling is here:

> **[Belajar Pemrograman Komputer dengan Yang Terbaik](https://www.codingforums.com)**
>
> Pelajari cara membuat program bersama kami, di sini Anda dapat mempelajari cara membuat halaman web yang indah menggunakan HTML dan CSS.

That said, why don’t you just use a standard login system (e.g.  
login\_generator, acts\_as\_authenticated, restful\_authentication) on the  
Rails side (or roll your own, as is done in AWDwR) rather than trying  
to get the Windows login name from Flex?

This would be more reliable than relying on JavaScript (which the user  
may have disabled) and IE (since I assume that the ActiveX solution  
shown at codingforums is IE-only). Furthermore, why limit yourself to  
Windows clients when you can support Mac clients as well with _less_  
effort on your part?

Cheers,  
Peter A.

P.S. Shameless plug: I have examples of Flex talking to Rails–both  
using login\_generator and using restful\_authentication–in my PDF-only  
book Flexible Rails ([http://www.flexiblerails.com](http://www.flexiblerails.com)). You can download  
its MIT-licensed source code for free from  
[http://www.flexiblerails.com/files/FlexibleRailsBookCode.zip](http://www.flexiblerails.com/files/FlexibleRailsBookCode.zip) to see  
how this works, regardless of whether you buy the book…

---

<div class="post-metadata">

**Author:** ![athind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@athind](https://www.ruby-forum.com/u/athind)\
**Post date:** [January 24, 2007, 12:53pm UTC](https://www.ruby-forum.com/t/windows-username-of-user/83187/3 "2007-01-24T12:53:56Z")

</div>

Aman Thind wrote:

> Thank you so much Peter!
> 
> Yes I’ve confirmed that Flash can not provide the windows loginname to  
> me.
> 
> I was bent on acquiring the windows username for authentication as I do  
> not want to prompt the user for a username or password.
> 
> The list of users allowed to operate the application is very small and  
> can be authenticated against their windows id to mimic a single-signon.
> 
> Do you think solutions like Net::LDAP or login\_generator could fit the  
> bill?

when i was trying to find a way to use windows authentication, the only  
way i could find was by using a webserver that itself understands  
windows-auth (so IIS for me). and then proxy the requests to mongrel(s)  
(or whatever server runs your rails app).

see my post with a little howto at [Finally solved: Windows Auth via IIS6 proxied to mongrel - Rails - Ruby-Forum](http://www.ruby-forum.com/topic/91247)

perhaps this helps,

ralf

---

<div class="post-metadata">

**Author:** ![athind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@athind](https://www.ruby-forum.com/u/athind)\
**Post date:** [January 24, 2007, 8:35am UTC](https://www.ruby-forum.com/t/windows-username-of-user/83187/4 "2007-01-24T08:35:42Z")

</div>

Thank you so much Peter!

Yes I’ve confirmed that Flash can not provide the windows loginname to  
me.

I was bent on acquiring the windows username for authentication as I do  
not want to prompt the user for a username or password.

The list of users allowed to operate the application is very small and  
can be authenticated against their windows id to mimic a single-signon.

Do you think solutions like Net::LDAP or login\_generator could fit the  
bill?

Many Thanks,  
Aman
