Ruby: Get currently logged in user on windows

前端 未结 6 1473
不思量自难忘°
不思量自难忘° 2021-01-13 04:20

In C# I can get the current user of a web app using the HttpContext, however, I can\'t figure out how to do this in Ruby. Is there any way of doing this?

FOR

6条回答
  •  自闭症患者
    2021-01-13 04:55

    Is your c# code running as a .NET plugin/client-side code or is it ENTIRELY server side? Your ruby code would be entirely server side. According to the MS docs, only stuff running in the CLR sandbox can really get to that information:

    http://msdn.microsoft.com/en-us/magazine/cc163700.aspx (under Defining the sandbox).

    One thing interesting to note is that sites registered under LocalIntranet have access to that information. I'm not sure off hand how this maps to security zones in IE though.

    The thing to understand is that LOGON_USER is NOT visible to the browser sandbox anymore than the browser can see the contents of a filesystem path on your system. The fact that your c# code sees it almost certainly indicitive of some clientside component passing it upstream.

    You have the option of implementing mod_ntlm under apache and pushing the headers downstream. I don't have the points to post a second link but google 'rails ntlm sso' and see the rayapps.com link.

    but if your app isn't Rails based, you'll have to port that to your server code. You can also checkout rack-ntlm if your app is rack compliant.

提交回复
热议问题