Solved

How to get Client's username in PHP web page?

Posted on 2010-11-11
7
8,223 Views
Last Modified: 2012-05-10
I'm creating a website in PHP to be used over INTRANET with the server running Windows NT and the clients running Windows XP Pro. All the clients log on to the server at windows startup.

Now, I want to use that login information to automatically log on to website as well. For this I need the ACCOUNT NAME (username) that the client used to login.

So, my question is, How to get windows account username of the client machine in PHP?

Here's some research I've done on this topic. I hope it assists in providing solution.

There's no direct way of getting the clients windows account username over INTERNET as it would be a security issue.
I have to use Internet Information Services (IIS) server on WIndows NT instead of Apache server to get the client's information.
Using this code in PHP we only get the username of the system where the server is running
<?php echo getenv("username"); ?>
If the user is logging on to the web server using a Windows domain (through NT authentication) then in ASP, I can get client's username using:
System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();Also, in ASP in can have the server impersonate the user by setting this in web.config file
<system.web> <identity impersonate="true" /> </system.web>I'm looking for a similar way in PHP
I can get client's username by using ActiveX in Javascript but it works only in Internet Explorer
var objUserInfo = new ActiveXObject(“WScript.network”);
0
Comment
Question by:thunderwonder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 5

Expert Comment

by:ByteSleuth
ID: 34110148
Hello Buddy,

in asp you can get the username using

Membership.GetUser().UserName

HTH

Bytes
0
 
LVL 2

Author Comment

by:thunderwonder
ID: 34110187
Thanks but I'm searching for a similar way in PHP
0
 
LVL 4

Accepted Solution

by:
Antyrael earned 500 total points
ID: 34110199
Would $_SERVER['LOGON_USER']  provide the correct username?

You could make a simply php script with the following lines, open it in your browser and look through the available variables:
<?php
phpinfo();
?>
0
Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

 
LVL 10

Expert Comment

by:abt-it
ID: 34110216
create a page with

<?php
phpinfo();
?>

Open this page in a browser from a logged in client and see if you can find a global var with the username.

But i think this is not possible because of security issues.
0
 
LVL 2

Author Comment

by:thunderwonder
ID: 34110268
Thanks. I don't have the network available right now to test it but I think this is what I was looking for. What settings I have to do in my IIS server to make it work? Cause surely, it would work only on INTRANET and not on INTERNET. Can I use Apache server as well to do the same thing?
0
 
LVL 13

Expert Comment

by:dsmile
ID: 34110270
I don't think PHP itself has such an ability.

If this is an INTRANET with Windows context then you should use PHP system() to run some windows command to achieve that :)
0
 
LVL 2

Author Comment

by:thunderwonder
ID: 34110404
Yeah I know it won't work directly. I have to do some INTRANET specific settings in IIS to achieve the result through $_SERVER['LOGON_USER']. I'll take 3-4 days to test this on network and work out IIS settings before closing this question. Thanks to everyone who replied. Meanwhile, if anyone has something to add, you're most welcome.
0

Featured Post

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

691 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