userid: who loged in Windows

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
t047554
Forum Newbie
Posts: 7
Joined: Mon Jun 16, 2003 6:58 am

userid: who loged in Windows

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You could get this value using PHP but are you looking for a JavaScript solution?

Mac
t047554
Forum Newbie
Posts: 7
Joined: Mon Jun 16, 2003 6:58 am

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
t047554
Forum Newbie
Posts: 7
Joined: Mon Jun 16, 2003 6:58 am

Post 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
User avatar
releasedj
Forum Contributor
Posts: 105
Joined: Tue Jun 17, 2003 6:35 am

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
t047554
Forum Newbie
Posts: 7
Joined: Mon Jun 16, 2003 6:58 am

Post 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
t047554
Forum Newbie
Posts: 7
Joined: Mon Jun 16, 2003 6:58 am

Post 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
Post Reply