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
Share on other sites

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.

Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.