Get windows username under IIS

Posted on 2012-08-30
Last Modified: 2012-09-10
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:-
	echo $_SERVER['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
Question by:tonelm54
    LVL 36

    Expert Comment

    by:Loganathan Natarajan
    did you enable Integrated windows authentication instead of anonymous access?

    Author Comment

    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
    LVL 2

    Accepted Solution

    check your folder permissions on the actual folders containing the data on your disc.  IIS is very particular about folder permissions.  Given that you ought to be securing within IIS it makes sense to set annomous access to the folders on the disc and then control permissions from within IIS.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now