Solved

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

Posted on 2010-11-11
7
7,349 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
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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
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 …

790 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