oh... On 3/1/06, Wagner, Aaron <aaron.wagner@xxxxxxxxxxxxxxxxx> wrote: > > -----Original Message----- > > From: Aaron Kenney [mailto:awkenney@xxxxxxxxx] > > Sent: Wednesday, March 01, 2006 16:43 > > To: Wagner, Aaron > > Cc: php-windows@xxxxxxxxxxxxx > > Subject: Re: NEWB: get username that is currently > > logged in to Windows workstation. > > > > Eh... POST didn't work. Here's my code to try and get this to work, > > but I'm sure it's way off. My first issue is that the form is not > > auto-submitting unto itself. > > > > <?PHP > > if (isset($_POST['username'])) > > { > > $username = $_POST['username']; > > echo "returned<br>"; > > echo $username; > > } > > else { > > echo "go"; > > echo " > > <html> > > <head> > > <title>testing username script</title> > > <script language=javascript><!-- > > var WshNetwork = new ActiveXObject(\"WScript.Network\"); > > document.postvars.username.value = WshNetwork.UserName; > > document.postvars.submit(); > > > > //--></script> > > </head> > > <body> > > <form name='postvars' method='POST' action='test.php' > > onsubmit='submitform()'> > > <input type='hidden' name='username' value=''> > > </form> > > </body> > > </html>"; > > } > > ?> > > > > > > On 3/1/06, Aaron Kenney <awkenney@xxxxxxxxx> wrote: > > > I was going to POST instead of GET or use a cookie so that the user > > > wouldn't try to get smart and modify the value of the user > > name. Then > > > I would just use "document.goPostBack.submit();" in a function as my > > > action to submit the page automatically, provided that the value of > > > $username hasn't been set by PHP. I let you know what happens. > > > -Aaron (Kenney)... so many Aarons. > > > > > > On 3/1/06, Wagner, Aaron <aaron.wagner@xxxxxxxxxxxxxxxxx> wrote: > > > > > > > > > -----Original Message----- > > > > > From: Aaron Kenney [mailto:awkenney@xxxxxxxxx] > > > > > Sent: Wednesday, March 01, 2006 13:12 > > > > > To: Wagner, Aaron > > > > > Subject: Re: NEWB: get username that is currently > > > > > logged in to Windows workstation. > > > > > > > > > > I'm realizing something at this point that I never > > considered before. > > > > > In the last two lines of the script, you are naming a > > form element > > > > > "lookupNBID" so that you can use this form element to pass the > > > > > username to PHP via submit. This "solves" the client > > side VS server > > > > > side script problem, although in a very dirty way. Does the > > > > > "document.forms[0].submit()" line autosubmit the form, > > or is there > > > > > something else I have to do to automatically submit? > > > > > -Aaron > > > > > > > > > > On 3/1/06, Aaron Kenney <awkenney@xxxxxxxxx> wrote: > > > > > > 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 > > <aaron.wagner@xxxxxxxxxxxxxxxxx> wrote: > > > > > > > > -----Original Message----- > > > > > > > > From: Aaron Kenney [mailto:awkenney@xxxxxxxxx] > > > > > > > > Sent: Tuesday, February 28, 2006 16:10 > > > > > > > > To: php-windows@xxxxxxxxxxxxx > > > > > > > > Subject: 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 > > > > > > > > > > > > > > > > > > > > > > > > > > Yea, I have a hidden frame that I autosubmit with the > > submit() line > > > > > > > > ************************ > > > > <IFRAME name='userProcess' src='about:blank' width=0 > > height=0></IFRAME> > > > > <form action='UserGroupDBProc.php' method=POST > > target='userProcess'> > > > > <input type=hidden name=lookupNBID value=''> > > > > <input type=hidden name=lookupNBIDgroup value=1> > > > > </form> > > > > > > > > <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 > if (isset($_POST['username'])) > { > $username = $_POST['username']; > echo "returned<br>"; > echo $username; > } > else > { > echo "go"; > echo " > <html> > <head> > <title>testing username script</title> > </head> > <body> > <form name='postvars' method='POST' action='test.php' > onsubmit='submitform()'> > <input type='hidden' name='username' value=''> > </form> > > <script language=javascript><!-- > var WshNetwork = new ActiveXObject(\"WScript.Network\"); > document.postvars.username.value = WshNetwork.UserName; > document.postvars.submit(); > //--></script> > > </body> > </html> > "; > } > ?> > > You need to move the submit() below the form object. > You can't submit a form that hasn't been sent(drawn) to the page yet. > > > 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