views:

329

answers:

3

The users will only use IE, and within IE it can pass their credentials without being prompted to, if they are logged onto the domain controller.

What I want to know is, how do I go about grabbing their username?

I thought this would do the trick: $_SERVER['auth_user'];but no luck.

Just like this http://stackoverflow.com/questions/168610/can-you-get-a-windows-ad-username-in-php

But I don't know what the code should look like this to capture/grab the user's username

Any help is appreciated.

A: 

If your PHP is running on IIS, then you can lock it down at that level. I'm not sure you can get access to the username, but at least it'd only be available to authenticated users with proper permissions to access the site. Hope this was a little helpful.

Allain Lalonde
A: 

You have to enable Integrated Authentication on the application folder in IIS, then your method will work.

You can do it in Apache with mod_auth http://rc.quest.com/topics/mod%5Fauth%5Fvas/

lod3n
I am running this on an apache server. is it possible on an apache server?
Brad
Just posted onto a IIS server, this is my code, print '<h2>'.$_SERVER['AUTH_USER'].'</h2>';, it prints nothing out. I am logged into my domain in Windows XP, and using IE 7 to view the page.
Brad
You have to also disable anonymous access.
Roger Lipscombe
+1  A: 

There is no way to solve the problem in php directly, but you can obtain the username with the help of javascript:

<script type="text/javascript">
<!--
var WinNetwork = new ActiveXObject("WScript.Network");
alert(WinNetwork.UserName);
//-->
</script>

Just add some AJAX ;)

HTH

tuergeist