Page 1 of 1

userid: who loged in Windows

Posted: Wed Jun 18, 2003 7:31 am
by t047554
Hi,

Is it possible to use the client side (userid: who loged in Windows) to fill the field userid for a authentification ?

Thank's

Posted: Wed Jun 18, 2003 7:46 am
by twigletmac
You could get this value using PHP but are you looking for a JavaScript solution?

Mac

Posted: Wed Jun 18, 2003 7:55 am
by t047554
I want to use PHP, the goal is to use a authentification form and to fill the field userid with the userid of windowsXP (a environment variables of Windows).

My question : is it possible with PHP to read who is loged in Windows(client side) and use it as a session variable?

thank's

Posted: Wed Jun 18, 2003 8:06 am
by twigletmac
Sorry to not help but continually ask questions - just to clarify, is this the users network login id or is it just the id they use to login to their local machine?

Mac

Posted: Wed Jun 18, 2003 8:27 am
by t047554
Np may be it's me(maybe I'm not clear enough).

I will say the id to login to their local machine. (is it a big difference on the windows variable if you log on localy or on the network?)

Thank's

Posted: Wed Jun 18, 2003 8:38 am
by releasedj
Using PHP, you can only get environment details of the local machine using the $_ENV variable.

On the client, it is possible in IE using an ActiveX object, but depending on the security level, they will be asked if they wish to run the ActiveX object.

Anyway, try the following:

Code: Select all

<html>
<head>
<script language="JavaScript">
<!--
function GetUserName ()
&#123;
    var WshShell = new ActiveXObject("Wscript.Shell");
    var WshEnv = WshShell.Environment("Process");
    var sUserName = WshEnv.Item("UserName");
    return sUserName;
&#125;

window.onload = function () &#123;document.login_form.username.value = GetUserName();&#125;
-->
</script>
</head>

<body>
<form name="login_form">
Username: <input type="text" name="username" value="" />
<br/>
Password: <input type="password" name="password" />
<input type="submit">
</form>
</body>
</html>
Good luck.

Posted: Wed Jun 18, 2003 8:44 am
by twigletmac
If you're logged into the network it's a lot easier as you can access the userid from the $_SERVER array (I think it's something like $_SERVER['REMOTE_USER']).

Mac

Posted: Wed Jun 18, 2003 9:08 am
by t047554
Thank's releasedj,

but as you say it is not working on all machines, I must find something else.

Thank's twigletmac,

I must look the $_SERVER array and try to find a solution that way.

thank you both of you.

regard's

Posted: Thu Jun 19, 2003 4:10 am
by t047554
I have try :
<?
$info = explode('\'',$_SERVER['REMOTE_USER']);
$username = $info[1];
echo $username;
echo $info[0];
echo $info[1];
?>
but I don't get anything.

Please help.

Rene