I'm working on a solution to identify client Network Domain or Workgroup in a private network. Based on it, I must change some access permissions.
I can't do that through IP address because it isn't trustable, only network domain/ workgroup.
For reasons unknown to me I can't have a login screen, access must be automatic and seamless.
Someone know how can I do it?
It's possible to get corresponding to a given IP address using gethostbyaddr
function http://php.net/manual/en/function.gethostbyaddr.php:
$proxy = (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : false;
if(!!$proxy){
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
echo "Warning: Your cliend is using proxy, may could not determine hostname";
}else{
$ipaddress = $_SERVER['REMOTE_ADDR']; //
}
$hostname = gethostbyaddr($ipaddress); //Its will return domain + machine-name inside a private network.
if($ipaddress == $hostname){
echo "Impossible to determine hostname for: ", $ipaddress ;
}else{
echo "The hostname for ", $ipaddress, "is : ", $hostname;
}
But the communication using application / session layer to network layer is a little complicated. You must don't trust it to access control in php applications.
To get all public IP Address is possible to use WebRTC (javascript) instead remote addrees from http header.