Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-11-11
7
Medium Priority
?
9,252 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 2000 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
Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
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 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 …
Suggested Courses

604 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