views:

1012

answers:

1

For a website on the Intranet with all the IE security settings setup. I want to retrieve the current AD username that the user is logged in with. I don't need to authenticate because I am assuming that the person on the computer has already gone through the process.

Is this even possible? I've seen a lot of NTLM related stuff that shows how to authenticate but I can't seem to pull the current authenticated username easily without a prompt box, which is what I'm trying to avoid.

The server setup is a Windows server with Apache. If it is easily done with a Linux machine I can move it there too.

+3  A: 

As stated in your question, IE has to be configured to allow Windows Integrated Authentication. Doing so basically gives IE permission to provide your credentials/token to sites that request it (usually limited to sites in the Intranet zone). Note that your web site will have to request those credentials (in IIS it is as simple as checking a checkbox). In Apache you'll have to find an Apache module that add NTLM authentication support to your web server. A quick Google search revealed a few different modules, none seemed particularly up to date. If you get an Apache NTLM module working, I suspect you'll be able to access the username via $_SERVER['AUTH_USER'].

chyne
I've found those modules for Apache too. However, they want to authenticate against AD a second time. This is not what I want it to do. I just want it to challenge IE (the modules can do) for the tokens and then let me pull the username out of that.
baens