knowram Posted May 15, 2007 Share Posted May 15, 2007 Is there anyway to get the username that is currently logged into a computer while visiting a page? Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/51574-get-weindows-login/ Share on other sites More sharing options...
Barand Posted May 15, 2007 Share Posted May 15, 2007 if you are on a windoze network <?php $domuser = $_SERVER['LOGON_USER']; //--> domain\username (or domain\\username) list ($domain, $username) = explode ("\\", $domuser); ?> With some versions you may need explode ("\\\\", $domuser) Quote Link to comment https://forums.phpfreaks.com/topic/51574-get-weindows-login/#findComment-254007 Share on other sites More sharing options...
knowram Posted May 16, 2007 Author Share Posted May 16, 2007 I tried just printing the $_Server['LOGON_USER'] variable and then printing the whole $_SERVER array and nothing comes up for the LOGON_USER entry. Any idea what could be causing this. Quote Link to comment https://forums.phpfreaks.com/topic/51574-get-weindows-login/#findComment-254544 Share on other sites More sharing options...
trq Posted May 16, 2007 Share Posted May 16, 2007 Are you testing this on a local windows network? Or trying to do it over the web? The later will not work. Quote Link to comment https://forums.phpfreaks.com/topic/51574-get-weindows-login/#findComment-254580 Share on other sites More sharing options...
AbydosGater Posted May 16, 2007 Share Posted May 16, 2007 You should have a look at this... <?php $nw = new COM("WScript.Network"); print "username0: " . $nw->username . "<br><br>"; $computername = $nw->computername; print "computername: $computername<br>"; $owmi = new COM("winmgmts:\\\\$computername\\root\\cimv2"); $comp = $owmi->get("win32_computersystem.name='$computername'"); print "username: " . $comp->username; ?> Hope it helps. Andy Quote Link to comment https://forums.phpfreaks.com/topic/51574-get-weindows-login/#findComment-254581 Share on other sites More sharing options...
MadTechie Posted May 16, 2007 Share Posted May 16, 2007 WScript is commonly disabled as its a secuirty risk Quote Link to comment https://forums.phpfreaks.com/topic/51574-get-weindows-login/#findComment-254585 Share on other sites More sharing options...
AbydosGater Posted May 16, 2007 Share Posted May 16, 2007 Yes but if its that important to him im sure he could get it enabled. Quote Link to comment https://forums.phpfreaks.com/topic/51574-get-weindows-login/#findComment-254589 Share on other sites More sharing options...
marf Posted May 16, 2007 Share Posted May 16, 2007 Hrm, curious, do the above methods work for Active Directory users on a Domain? Quote Link to comment https://forums.phpfreaks.com/topic/51574-get-weindows-login/#findComment-254618 Share on other sites More sharing options...
AbydosGater Posted May 16, 2007 Share Posted May 16, 2007 Marf: Yes, i have looked it up on google and from what i can tell. Yes it does work with Active Directory. Andy Quote Link to comment https://forums.phpfreaks.com/topic/51574-get-weindows-login/#findComment-254665 Share on other sites More sharing options...
knowram Posted May 16, 2007 Author Share Posted May 16, 2007 Hmm the WScript worked but it gave me the wrong user name. example: I have a server on my network hosting this site which requires a login to associate some features with the individual that is using the site. I would like to be able to pull the user name of the person hitting the site so I can use that instead of having them go through a login page. Any ideas?? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/51574-get-weindows-login/#findComment-254797 Share on other sites More sharing options...
Barand Posted May 16, 2007 Share Posted May 16, 2007 I forgot to mention, you have to disable anonymous login (at least if IIS is used - that's the only one I tried it with) Quote Link to comment https://forums.phpfreaks.com/topic/51574-get-weindows-login/#findComment-254805 Share on other sites More sharing options...
knowram Posted May 16, 2007 Author Share Posted May 16, 2007 Well I have two servers on is A windows box running IIS and it dose have anonymous login enabled(which I can't disable) and a Mac os x box with apache running. On the IIS box it dose not give me anything for that value. On the apache box it doesn't even show that variable. I will try it on yet another server when I get home. Quote Link to comment https://forums.phpfreaks.com/topic/51574-get-weindows-login/#findComment-254827 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.