I just installed Apache 2 and PHP 5.0.4 on my Windows XP SP2 box, however when I run phpinfo() there is no PHP_AUTH_USER variable appearing on the page. I installed PHP as Apache module and when phpinfo() is ran I can see that it says "Apache 2.0 Handler " in the Server API. Is there something I have to set on Apache or PHP to make PHP_AUTH_USER variable become available?

Thanks.

    $_SERVER['PHP_AUTH_USER'] will only show up if a request is made including a username/password pair like http://user:pass@www.site.com/page.php. After that point the browser should make it invisible in the url but continue sending the auth info in the http headers.

      drew010,

      Thank you for your reply. What I ultimately want to do is capture login name of the person that is logged in to the workstation, so I can use that name in LDAP to query our Active Directory. I used to be able to do it with earlier versions of PHP but I can't seem to make it work with PHP 5.0.4. When I do $_SERVER['PHP_AUTH_USER'] the server doesn't return anything.

      Any ideas?

        php auth user wont get the username of the person logged into windows, it is related to HTTP authentication (password protected folders on the webserver). you might be able to use the USER_PROFILE environment variable to figure out which user is on.

          drew010,

          I never heard about USER_PROFILE environment variable. How do you use it?

            actually it will really just print the username php was run under from the server, and wont have anything to do with the user visiting the page.
            the problem is that php is running on the server and the user visiting the page from the browser will send no information as to what their username is, even if they are using windows or linux.

              Write a Reply...