PHP 7 - Logged in user(AD) and hostname

Asked

Viewed 1,479 times

3

I’ve already searched the Stackoverflow En and PT, google and only found things like getenv(), $_SERVER['user'],shell_exec() or anything that returns me data from the Web server, nothing from the logged user on the system.

Another solution, nothing viable, was to use the ActiveX, that would only work in IE, no chance.

The solution until the moment I found was to create a Webservice in . Net, which only returns me the local user, nothing very difficult, but annoying to have q use another app besides the default in php, on another server.

As for the name of the machine, I already have the ip local via $_SERVER, but I need the name of the local machine even running Dig with shell_exec doesn’t happen.

So, of the 2 questions, search the user(ad) by PHP I imagine that I have not really left, but what about fetching the name of the local machine?

  • 1

    You want to get the client machine name on the server side?

  • N understood.. the application runs on the server.

1 answer

0

Try doing by running the following command.

<?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
echo $hostname;
?>

Testing it worked perfectly, I understood what I understood what you want

Source

  • gethostbyaddr returns me the IP if I use gethostbyname tb..

  • Try echo getenv("USERNAME");

  • 1

    ah... if u are running the local web server, it will probably return everything, even the network user running shell_exec('echo %username%'), but since the server is the part, it probably should be why it does not scroll.

  • 1

    If you put the ip inside the gethostbyaddr? What rolls?

  • 1

    echo(gethostbyaddr($_SERVER['REMOTE_ADDR'])); -me.u.i.p echo(gethostbyname($_SERVER['REMOTE_ADDR']); -me.u.i.p

Browser other questions tagged

You are not signed in. Login or sign up in order to post.