Jump to content

Logged on user


New Coder

Recommended Posts

Hello all,

 

This has probably been asked before but I couldn't find through search.

 

And I'm pretty sure is not possible, but...

 

Is there a way of displaying the windows logged on user?

or

get the name of the compter? as I know I can get the ip address.

 

The reason I ask.

Each user has their own network account but on occasion we need to log on a user as a generic account we have. And I want to check if it's this user accessing the page so different options etc can be displayed.

I could use the computer name to check this as we log all activity. I could then query the log using the comp name to find logged on user.

Unfortunately the log does not hold ip, which would seem obvious but it doesn't  :(

 

Many Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/224826-logged-on-user/
Share on other sites

I couldn't seem to get what I wanted so I used Javascript

 

On the index page I added:

<script type="text/javascript">

var WinNetwork = new ActiveXObject("WScript.Network");

var User_Name = WinNetwork.userName;

window.location.href = "mainpage.php" + "?User_Name=" + encodeURIComponent(User_Name);

</script>

 

Then on mainpage I added:

if($_GET['User_Name'] == "GenericAccName")

{

header("Location:genaccmain.php");

exit();

}

 

Bit quick and dirty but until i find a better solution it's working to my needs.

 

Many Thanks

Link to comment
https://forums.phpfreaks.com/topic/224826-logged-on-user/#findComment-1161846
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.