0

I am trying to get the clients username from server which in on the intranet. Im using mozilla firefox and chrome only. I am able to get the information like Client PC Name and Client Pc IP. How can i get the username for the client who access the website on intranet.

The code i am using is below

<?php
    $compt = gethostbyaddr($_SERVER['REMOTE_ADDR']);
     // i get complete pc name like example: abbc123.abc.google.com
    $compt_name = $issued_for = strtok($compt,'.');
    //i get the pc name abbc123
    echo $compt_name;
    ?>

how can i use the computer name to get the username? i have tried searching but cant find anything that will work. im using PHP and all answers i get is for c# , Vb etc. The server is running windows server 2012

Alz
  • 351
  • 5
  • 17
  • 1
    possible duplicate of [Can you get a Windows (AD) username in PHP?](http://stackoverflow.com/questions/168610/can-you-get-a-windows-ad-username-in-php) – naththedeveloper Aug 20 '14 at 07:31

1 Answers1

0

It is because C# and VB are desktop applications and can access system's username. PHP, however, is a web application that can not access system resources beyond the purview of a web browser.

What you can do, however, is use a java application to fetch the user name from a computer and pass it to PHP.

Basit
  • 1,830
  • 2
  • 31
  • 50
  • by java you mean javascript? is there a possibility that as its INTRANET i can get username from pcname or ip address.?? – Alz Aug 20 '14 at 07:50
  • C# and VB applications are not always desktop applications, and he is not limited to Java to accomplish this. Although he did not directly mention authentication, still the correct way to accomplish this is more likely using windows authentication. – mstrthealias Aug 20 '14 at 07:51