Fetch username

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have two servers in my Intranet environment and we only use Windows
workstations to login to the Intranet and view the Intranet web pages.
The two web servers in my Intranet are Windows and Solaris. On the
Windows Intranet server (with Windows Integrated authentication turned
on) I can fetch the Intranet Windows login username using
CGI.Auth_User in ColdFusion page. Please advise how I can fetch
Windows login username using PHP 5 on Solaris 10 server? I tried many
different attempts and none of them printed anything.

Here is what I used:

echo $_ENV["USERNAME"];
echo $_ENV['USERNAME'];

Please advise.

Re: Fetch username

teser3@hotmail.com wrote:
Quoted text here. Click to load it

Start with the docs:


This is not guaranteed to work unless you enable scripting - something
for which you have no control.

Re: Fetch username

In article

Quoted text here. Click to load it

These attributes are considered unreliable and should not be used for
authentication as they can be spoofed.  If you setup a web page on an
Apache server to require a login through .htpass, then Apache will
return $_SERVER["AUTH_USER"] (read the PHP manual for the difference
between associate arrays with single vs. double quotes).  
$_ENV["USERNAME"] is a function of the shell environment under which
Apache runs.  Chances are it's not the user logging in.

You can add a module to your Apache server to authorize against Windows
domains, but it's Apache, not PHP that's doing the authorization.  PHP
just reports the results:

http://sourceforge.net/projects/modntlm /

Here's a thread that discusses the problem:


DeeDee, don't press that button!  DeeDee!  NO!  Dee...
[I filter all Goggle Groups posts, so any reply may be automatically by ignored]

Re: Fetch username

teser3@hotmail.com wrote:
Quoted text here. Click to load it

what do you mean by 'login'?

Quoted text here. Click to load it

When exactly do you 'login' to the solaris server?

Quoted text here. Click to load it

Re: Fetch username


on 02/11/2009 01:13 AM teser3@hotmail.com said the following:
Quoted text here. Click to load it

You need to install mod_ntlm (assuming you are using Apache on Solaris),
configure it to require NTLM authentication using your Windows domain,
and then use $_SERVER['LOGON_USER'] to authenticated user name.


Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs /

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org /

Re: Fetch username

I think this has already been said but I'll say it more plainly. If
you want to authenticate, require the user to authenticate to the
server via a login page.


teser3@hotmail.com wrote:
Quoted text here. Click to load it

Ron Fox
Michigan State University
East Lansing, MI 48824-1321

Re: Fetch username

Quoted text here. Click to load it

Thanks, still cant get any value.  It looks like from all the
responses there is not anything that has to be turned on the Solaris
10 server like authentication and I will need third party software
(NTLM from sourceforce) to make this work on the Apache on Solaris web

I guess I can always use a ColdFusion page on IIS in my intranet
evironment to fetch the username and store it in a database and use
PHP for other parts of my application.

Site Timeline