1

I'm trying to get the name of the user who access my webserver. I know how to get the name of the computer which is connected to the server:

$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);  

and i'm looking for a way to get the user who is opened the session in the computer. Is there a way to do this?

Albzi
  • 15,431
  • 6
  • 46
  • 63
Dev DOS
  • 1,018
  • 4
  • 18
  • 45
  • 5
    You want to know the _remote users'_ usernames on their own systems? Not possible unless they have logged into your site, which would tell you their username as registered on _your site_. – Michael Berkowski Jun 09 '14 at 14:13
  • 1
    Not possible. PHP has NO access of that sort to the user's computer, and would be a hideous security/privacy breach even if it did. At **BEST** you could try and see if `identd` is running, but the odds of that actually happening are somewhat lower than 0%. – Marc B Jun 09 '14 at 14:15
  • 1
    PHP is server side and has no knowledge of application level data other than what the browser can provide at the page load. – Silvertiger Jun 09 '14 at 14:16
  • ok then i'll throw this idea and work just with the $hostname. thank you all. – Dev DOS Jun 09 '14 at 14:16

2 Answers2

5

In one word: No.

You cannot reach into remote computers and pull out any kind of information you want. Thank god. So unless the username is voluntarily advertised by the remote computer as part of some protocol or another, you cannot get it. And the username is not typically disclosed as part of any regular HTTP protocol traffic.

deceze
  • 510,633
  • 85
  • 743
  • 889
0

Take a look at the AUTH_USER request variable. PS: It wont work unless you have LDAP/Active Directory and provided your server doesnot allow anoynimous login. If both seneriaos are OK, IE wil send over the user, normally might not work for other browsers

Similar question : Can you get a Windows (AD) username in PHP?

Community
  • 1
  • 1