Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

Get windows username under IIS

Im trying to create a simple page, and at the top say
Welcome User

I would like to get the windows username and replace user in Welcome, so for example 'Welcome tcross'.

Reading some documents this should be easy as Im using PHP under IIS, so I should be able to use:-
<?php
	echo $_SERVER['LOGON_USER'];
	echo $_SERVER['AUTH_USER'];
	echo $_SERVER['REDIRECT_LOGON_USER'];
	echo $_SERVER['REDIRECT_AUTH_USER'];
?>

Open in new window


But all I get is:-
Notice: Undefined index: REDIRECT_LOGON_USER in C:\inetpub\wwwroot\test.php on line 4

Notice: Undefined index: REDIRECT_AUTH_USER in C:\inetpub\wwwroot\test.php on line 5

Is there something Im missing? Is there something I need to enable in IIS?

Thank you
Avatar of Loganathan Natarajan
Loganathan Natarajan
Flag of India image

did you enable Integrated windows authentication instead of anonymous access?
Avatar of tonelm54
tonelm54

ASKER

Ok, well that was my first mistake then. Installed it and it now works if I do it from the localhost and displays my username great. However if I access the page from different machines, I get:-
401 - Unauthorized: Access is denied due to invalid credentials.

Any ideas?

Thank you
ASKER CERTIFIED SOLUTION
Avatar of -CPG-
-CPG-

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial