Win32 Getting username from windows
| From: | Gastovski \(James\) | Date: | Sat, 17 Jan 2004 23:27:35 +0000 |
| Subject: | Win32 Getting username from windows | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-174941@lists.php.net to get a copy of this message | ||
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?
Many Thanks - James Gastovski
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.553 / Virus Database: 345 - Release Date: 18/12/2003