The Javascript idea would work, but I don't understand what is really
going on in the script.
var WshNetwork = new ActiveXObject("WScript.Network");
I guess this declares a variable, but I know nothing of ActiveX, since
it's about to be deprecated anyway, I never bothered to learn it. I am
going to assume that WScript.Network is a "superglobal" ActiveX array.
//document.write(WshNetwork.UserName);
//document.writeln(WshNetwork.UserDomain)
If these were uncommented, I am assuming they would display the
"UserName" and "UserDomain." I guess there should be a semicolon at
the end of the second line. :-P At this point though, I wouldn't want
to display this info, just assign it to a variable or cookie so i can
get at it with PHP. I suppose in this case I can always echo the JS
within PHP to get it to assign to a PHP variable. Maybe?
document.forms[0].lookupNBID.value = WshNetwork.UserName
document.forms[0].submit()
Here is where I am confused. Generally speaking, at this point, I just
want to get the username assigned to a PHP variable. But what happens
here? I guess you are naming a form element and then comparing that to
the current username upon submit, but what good is that if you do not
also authenticate the password?
I guess I'm missing the second part of my question which is to get the
username assigned to a PHP variable. How do I do this?
-Aaron
On 3/1/06, Wagner, Aaron <[EMAIL PROTECTED]> wrote:
> > -----Original Message-----
> > From: Aaron Kenney [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, February 28, 2006 16:10
> > To: [email protected]
> > Subject: [PHP-WIN] NEWB: get username that is currently
> > logged in to Windows workstation.
> >
> > I am sorry but I am somewhat new to interfacing Windows through PHP.
> > What I am trying to do is to get the username (or otherwise unique
> > identifier) of the user that is currently logged into the local
> > Windows workstation, and then assign the username to a variable. Can
> > it be done?
> > Originally what I considered doing was, in ASP, obtain the username
> > and write it to a cookie. Then use PHP to parse the cookie to get the
> > username.
> > -Aaron
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> I'm working on the same kind of issue. The problem I'm having is that
> PHP is a server-side script and can only see what is passed back to it
> in the browser. You can try to run a phpinfo and see what is passed
> back to PHP.
>
> I've actually had to go to a client-side script to see the user
> information and pass that back to the server. ActiveX and VBScript(I
> know, I hate it too) are the only processes I found that can get out of
> the 'sandbox' and read local user info.
>
> *****this queries active directory and gets your full name******
> <script language="VBScript">
> Set sysinfo = CreateObject("ADSystemInfo")
> Set oUser = GetObject("LDAP://" & sysinfo.UserName & "")
> Document.writeln("Name: <b>" & oUser.FirstName & " " &
> oUser.LastName & "</b><br>")
> //Document.writeln(sysinfo.UserName)
> </script>
>
> ************this gets username and domain**************
> <script language=javascript>
> var WshNetwork = new ActiveXObject("WScript.Network");
> //document.write(WshNetwork.UserName);
> //document.writeln(WshNetwork.UserDomain)
> document.forms[0].lookupNBID.value = WshNetwork.UserName
> document.forms[0].submit()
> </script>
>
> Thanx
> Aaron N Wagner
> Monitoring Systems and Network Tools
> CCO-Command Center Operations
> 804.515.6298
>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php