Re: Win32 Getting username from windows
| From: | John W. Holmes | Date: | Sun, 18 Jan 2004 01:29:52 +0000 |
| Subject: | Re: Win32 Getting username from windows | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-174944@lists.php.net to get a copy of this message | ||
Gastovski (James) wrote:
I'm using the following code to extract the username running on the windows machine: [start code] $api = new win32; $api->registerfunction("long GetUserName (string &a, int &b) From advapi32.dll"); $len = 255; $name = str_repeat("\0", $len); if ($api->GetUserName($name, $len) == 0) { die("failed"); } [end code] However when I 'echo ($name);' I get the value SYSTEM. This is correct, because advapi32.dll is probably being run by SYSTEM user on windows. However I need to get the name of the person logged onto the computer, not the SYSTEM running processes in the background. Is there any way of doing this?Try $_SERVER['LOGON_USER']. With IIS, you will need to disable anonymous access. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com