Solved

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

Posted on 2010-11-11
7
6,567 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now