There should be REMOTE_USER enviroment variable following the original [CGI standard](http://www.ietf.org/rfc/rfc3875.txt). In this case domain username can be accesable by _SERVER['REMOTE_USER'] in PHP or request.env['REMOTE_USER'] in Ruby on Rails. It is very important part of SSO-based authentication. For example [mod_spnego](https://github.com/lha/mod_spnego) and [mod_auth_kerb](http://modauthkerb.sourceforge.net/) for Apache2 do it.