Solved

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

Posted on 2010-11-11
7
6,915 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Calculate values in an array 18 36
Animated .jpg? 13 62
Form not operating correctly. 1 23
WordPress syntax 2 28
The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

863 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

28 Experts available now in Live!

Get 1:1 Help Now