New Coder Posted January 18, 2011 Share Posted January 18, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/224826-logged-on-user/ Share on other sites More sharing options...
trq Posted January 18, 2011 Share Posted January 18, 2011 Is this within an intranet environment? The data you seek should be within the $_SERVER array. Quote Link to comment https://forums.phpfreaks.com/topic/224826-logged-on-user/#findComment-1161278 Share on other sites More sharing options...
New Coder Posted January 18, 2011 Author Share Posted January 18, 2011 Is this within an intranet environment? The data you seek should be within the $_SERVER array. Yes, correct. I looked into that but could only find the ip which I can't use. $_SERVER['REMOTE_HOST'] Is there one for computer name? Many Thanks Quote Link to comment https://forums.phpfreaks.com/topic/224826-logged-on-user/#findComment-1161294 Share on other sites More sharing options...
trq Posted January 18, 2011 Share Posted January 18, 2011 You will need to print_r() the $_SERVER array and have a look, I0'm at home and am not sure of the key exactly. I have used similar mechanisms at work however. PS: This data is only passed when the clients are using IE also. Quote Link to comment https://forums.phpfreaks.com/topic/224826-logged-on-user/#findComment-1161297 Share on other sites More sharing options...
New Coder Posted January 19, 2011 Author Share Posted January 19, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/224826-logged-on-user/#findComment-1161846 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.